Remove most of Twitter code as Twitter's API access has been removed

This commit is contained in:
2023-04-03 13:35:05 -06:00
parent 74fe437684
commit 8acebc290b
95 changed files with 74 additions and 7643 deletions

View File

@@ -1 +0,0 @@
from . import baseDialog, trends, configuration, lists, search, find, show_user, update_profile, urlList, userSelection, utils, filterDialogs, userAliasDialogs

View File

@@ -95,45 +95,6 @@ class proxy(wx.Panel, baseDialog.BaseWXDialog):
sizer.Add(serverBox, 0, wx.ALL, 5)
self.SetSizer(sizer)
class generalAccount(wx.Panel, baseDialog.BaseWXDialog):
def __init__(self, parent):
super(generalAccount, self).__init__(parent)
sizer = wx.BoxSizer(wx.VERTICAL)
userAutocompletionBox = wx.StaticBox(self, label=_("User autocompletion settings"))
self.userAutocompletionScan = wx.Button(self, wx.ID_ANY, _("Scan account and add friends and followers to the user autocompletion database"))
self.userAutocompletionManage = wx.Button(self, wx.ID_ANY, _("Manage autocompletion database"))
autocompletionSizer = wx.StaticBoxSizer(userAutocompletionBox, wx.HORIZONTAL)
autocompletionSizer.Add(self.userAutocompletionScan, 0, wx.ALL, 5)
autocompletionSizer.Add(self.userAutocompletionManage, 0, wx.ALL, 5)
sizer.Add(autocompletionSizer, 0, wx.ALL, 5)
self.relative_time = wx.CheckBox(self, wx.ID_ANY, _(U"Relative timestamps"))
sizer.Add(self.relative_time, 0, wx.ALL, 5)
tweetsPerCallBox = wx.BoxSizer(wx.HORIZONTAL)
tweetsPerCallBox.Add(wx.StaticText(self, -1, _(u"Items on each API call")), 0, wx.ALL, 5)
self.itemsPerApiCall = wx.SpinCtrl(self, wx.ID_ANY)
self.itemsPerApiCall.SetRange(0, 200)
self.itemsPerApiCall.SetSize(self.itemsPerApiCall.GetBestSize())
tweetsPerCallBox.Add(self.itemsPerApiCall, 0, wx.ALL, 5)
sizer.Add(tweetsPerCallBox, 0, wx.ALL, 5)
self.reverse_timelines = wx.CheckBox(self, wx.ID_ANY, _(u"Inverted buffers: The newest tweets will be shown at the beginning while the oldest at the end"))
sizer.Add(self.reverse_timelines, 0, wx.ALL, 5)
lbl = wx.StaticText(self, wx.ID_ANY, _(u"Retweet mode"))
self.retweet_mode = wx.ComboBox(self, wx.ID_ANY, choices=[_(u"Ask"), _(u"Retweet without comments"), _(u"Retweet with comments")], style=wx.CB_READONLY)
rMode = wx.BoxSizer(wx.HORIZONTAL)
rMode.Add(lbl, 0, wx.ALL, 5)
rMode.Add(self.retweet_mode, 0, wx.ALL, 5)
sizer.Add(rMode, 0, wx.ALL, 5)
self.show_screen_names = wx.CheckBox(self, wx.ID_ANY, _(U"Show screen names instead of full names"))
sizer.Add(self.show_screen_names, 0, wx.ALL, 5)
self.hide_emojis = wx.CheckBox(self, wx.ID_ANY, _("hide emojis in usernames"))
sizer.Add(self.hide_emojis, 0, wx.ALL, 5)
PersistSizeLabel = wx.StaticText(self, -1, _(u"Number of items per buffer to cache in database (0 to disable caching, blank for unlimited)"))
self.persist_size = wx.TextCtrl(self, -1)
sizer.Add(PersistSizeLabel, 0, wx.ALL, 5)
sizer.Add(self.persist_size, 0, wx.ALL, 5)
self.load_cache_in_memory = wx.CheckBox(self, wx.NewId(), _("Load cache for tweets in memory (much faster in big datasets but requires more RAM)"))
self.SetSizer(sizer)
class reporting(wx.Panel, baseDialog.BaseWXDialog):
def __init__(self, parent):
super(reporting, self).__init__(parent)
@@ -240,130 +201,6 @@ class other_buffers(wx.Panel):
buffers_list.append(self.buffers.get_text_column(i, 0))
return buffers_list
class templates(wx.Panel, baseDialog.BaseWXDialog):
def __init__(self, parent, tweet_template, dm_template, sent_dm_template, person_template):
super(templates, self).__init__(parent)
sizer = wx.BoxSizer(wx.VERTICAL)
self.tweet = wx.Button(self, wx.ID_ANY, _("Edit template for tweets. Current template: {}").format(tweet_template))
sizer.Add(self.tweet, 0, wx.ALL, 5)
self.dm = wx.Button(self, wx.ID_ANY, _("Edit template for direct messages. Current template: {}").format(dm_template))
sizer.Add(self.dm, 0, wx.ALL, 5)
self.sent_dm = wx.Button(self, wx.ID_ANY, _("Edit template for sent direct messages. Current template: {}").format(sent_dm_template))
sizer.Add(self.sent_dm, 0, wx.ALL, 5)
self.person = wx.Button(self, wx.ID_ANY, _("Edit template for persons. Current template: {}").format(person_template))
sizer.Add(self.person, 0, wx.ALL, 5)
self.SetSizer(sizer)
class ignoredClients(wx.Panel):
def __init__(self, parent, choices):
super(ignoredClients, self).__init__(parent=parent)
sizer = wx.BoxSizer(wx.VERTICAL)
label = wx.StaticText(self, -1, _(u"Ignored clients"))
self.clients = wx.ListBox(self, -1, choices=choices)
self.clients.SetSize(self.clients.GetBestSize())
clientsBox = wx.BoxSizer(wx.HORIZONTAL)
clientsBox.Add(label, 0, wx.ALL, 5)
clientsBox.Add(self.clients, 0, wx.ALL, 5)
self.add = wx.Button(self, -1, _(u"Add client"))
self.remove = wx.Button(self, -1, _(u"Remove client"))
btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(self.add, 0, wx.ALL, 5)
btnBox.Add(self.remove, 0, wx.ALL, 5)
sizer.Add(clientsBox, 0, wx.ALL, 5)
sizer.Add(btnBox, 0, wx.ALL, 5)
self.SetSizer(sizer)
def append(self, client):
self.clients.Append(client)
def get_clients(self):
return self.clients.GetCount()
def get_client_id(self):
return self.clients.GetSelection()
def remove_(self, id):
self.clients.Delete(id)
class sound(wx.Panel):
def __init__(self, parent, input_devices, output_devices, soundpacks):
wx.Panel.__init__(self, parent)
sizer = wx.BoxSizer(wx.VERTICAL)
volume = wx.StaticText(self, -1, _(u"Volume"))
self.volumeCtrl = wx.Slider(self)
# Connect a key handler here to handle volume slider being inverted when moving with up and down arrows.
# see https://github.com/manuelcortez/TWBlue/issues/261
widgetUtils.connect_event(self.volumeCtrl, widgetUtils.KEYPRESS, self.on_keypress)
self.volumeCtrl.SetRange(0, 100)
self.volumeCtrl.SetSize(self.volumeCtrl.GetBestSize())
volumeBox = wx.BoxSizer(wx.HORIZONTAL)
volumeBox.Add(volume, 0, wx.ALL, 5)
volumeBox.Add(self.volumeCtrl, 0, wx.ALL, 5)
sizer.Add(volumeBox, 0, wx.ALL, 5)
self.session_mute = wx.CheckBox(self, -1, _(u"Session mute"))
sizer.Add(self.session_mute, 0, wx.ALL, 5)
output_label = wx.StaticText(self, -1, _(u"Output device"))
self.output = wx.ComboBox(self, -1, choices=output_devices, style=wx.CB_READONLY)
self.output.SetSize(self.output.GetBestSize())
outputBox = wx.BoxSizer(wx.HORIZONTAL)
outputBox.Add(output_label, 0, wx.ALL, 5)
outputBox.Add(self.output, 0, wx.ALL, 5)
sizer.Add(outputBox, 0, wx.ALL, 5)
input_label = wx.StaticText(self, -1, _(u"Input device"))
self.input = wx.ComboBox(self, -1, choices=input_devices, style=wx.CB_READONLY)
self.input.SetSize(self.input.GetBestSize())
inputBox = wx.BoxSizer(wx.HORIZONTAL)
inputBox.Add(input_label, 0, wx.ALL, 5)
inputBox.Add(self.input, 0, wx.ALL, 5)
sizer.Add(inputBox, 0, wx.ALL, 5)
soundBox = wx.BoxSizer(wx.VERTICAL)
soundpack_label = wx.StaticText(self, -1, _(u"Sound pack"))
self.soundpack = wx.ComboBox(self, -1, choices=soundpacks, style=wx.CB_READONLY)
self.soundpack.SetSize(self.soundpack.GetBestSize())
soundBox.Add(soundpack_label, 0, wx.ALL, 5)
soundBox.Add(self.soundpack, 0, wx.ALL, 5)
sizer.Add(soundBox, 0, wx.ALL, 5)
self.indicate_audio = wx.CheckBox(self, -1, _(u"Indicate audio tweets with sound"))
sizer.Add(self.indicate_audio, 0, wx.ALL, 5)
self.indicate_geo = wx.CheckBox(self, -1, _(u"Indicate geotweets with sound"))
sizer.Add(self.indicate_geo, 0, wx.ALL, 5)
self.indicate_img = wx.CheckBox(self, -1, _(u"Indicate tweets containing images with sound"))
sizer.Add(self.indicate_img, 0, wx.ALL, 5)
self.SetSizer(sizer)
def on_keypress(self, event, *args, **kwargs):
""" Invert movement of up and down arrow keys when dealing with a wX Slider.
See https://github.com/manuelcortez/TWBlue/issues/261
and http://trac.wxwidgets.org/ticket/2068
"""
keycode = event.GetKeyCode()
if keycode == wx.WXK_UP:
return self.volumeCtrl.SetValue(self.volumeCtrl.GetValue()+1)
elif keycode == wx.WXK_DOWN:
return self.volumeCtrl.SetValue(self.volumeCtrl.GetValue()-1)
event.Skip()
def get(self, control):
return getattr(self, control).GetStringSelection()
class extrasPanel(wx.Panel):
def __init__(self, parent, ocr_languages=[], translation_languages=[]):
super(extrasPanel, self).__init__(parent)
mainSizer = wx.BoxSizer(wx.VERTICAL)
OCRBox = wx.StaticBox(self, label=_(u"Language for OCR"))
self.ocr_lang = wx.ListBox(self, -1, choices=ocr_languages)
self.ocr_lang.SetSize(self.ocr_lang.GetBestSize())
ocrLanguageSizer = wx.StaticBoxSizer(OCRBox, wx.HORIZONTAL)
ocrLanguageSizer.Add(self.ocr_lang, 0, wx.ALL, 5)
mainSizer.Add(ocrLanguageSizer, 0, wx.ALL, 5)
lbl = wx.StaticText(self, wx.ID_ANY, _(u"API Key for SndUp"))
self.sndup_apiKey = wx.TextCtrl(self, -1)
sndupBox = wx.BoxSizer(wx.HORIZONTAL)
sndupBox.Add(lbl, 0, wx.ALL, 5)
sndupBox.Add(self.sndup_apiKey, 0, wx.ALL, 5)
mainSizer.Add(sndupBox, 0, wx.ALL, 5)
self.SetSizer(mainSizer)
class configurationDialog(baseDialog.BaseWXDialog):
def set_title(self, title):
self.SetTitle(title)
@@ -384,35 +221,6 @@ class configurationDialog(baseDialog.BaseWXDialog):
self.proxy = proxy(self.notebook, proxyTypes)
self.notebook.AddPage(self.proxy, _(u"Proxy"))
def create_general_account(self):
self.general = generalAccount(self.notebook)
self.notebook.AddPage(self.general, _(u"General"))
self.general.SetFocus()
def create_reporting(self):
self.reporting = reporting(self.notebook)
self.notebook.AddPage(self.reporting, _(u"Feedback"))
def create_other_buffers(self):
self.buffers = other_buffers(self.notebook)
self.notebook.AddPage(self.buffers, _(u"Buffers"))
def create_ignored_clients(self, ignored_clients_list):
self.ignored_clients = ignoredClients(self.notebook, ignored_clients_list)
self.notebook.AddPage(self.ignored_clients, _(u"Ignored clients"))
def create_templates(self, tweet_template, dm_template, sent_dm_template, person_template):
self.templates = templates(self.notebook, tweet_template=tweet_template, dm_template=dm_template, sent_dm_template=sent_dm_template, person_template=person_template)
self.notebook.AddPage(self.templates, _("Templates"))
def create_sound(self, output_devices, input_devices, soundpacks):
self.sound = sound(self.notebook, output_devices, input_devices, soundpacks)
self.notebook.AddPage(self.sound, _(u"Sound"))
def create_extras(self, ocr_languages=[], translator_languages=[]):
self.extras = extrasPanel(self.notebook, ocr_languages, translator_languages)
self.notebook.AddPage(self.extras, _(u"Extras"))
def realize(self):
self.sizer.Add(self.notebook, 0, wx.ALL, 5)
ok_cancel_box = wx.BoxSizer(wx.HORIZONTAL)

View File

@@ -1,150 +0,0 @@
# -*- coding: utf-8 -*-
import wx
import widgetUtils
from . import baseDialog
from multiplatform_widgets import widgets
class filterDialog(baseDialog.BaseWXDialog):
def __init__(self, value="", languages=[]):
super(filterDialog, self).__init__(None, -1)
self.langs_list = languages
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetTitle(_(u"Create a filter for this buffer"))
label = wx.StaticText(panel, wx.ID_ANY, _(u"Filter title"))
self.title = wx.TextCtrl(panel, -1, value)
dc = wx.WindowDC(self.title)
dc.SetFont(self.title.GetFont())
self.title.SetSize(dc.GetTextExtent("0"*40))
self.title.SetFocus()
tsizer = wx.BoxSizer(wx.HORIZONTAL)
tsizer.Add(label, 0, wx.ALL, 5)
tsizer.Add(self.title, 0, wx.ALL, 5)
sizer.Add(tsizer, 0, wx.ALL, 5)
staticbox = wx.StaticBox(panel, label=_(u"Filter by word"))
self.contains = wx.RadioButton(panel, -1, _(u"Ignore tweets wich contain the following word"), style=wx.RB_GROUP)
self.doesnt_contain = wx.RadioButton(panel, -1, _(u"Ignore tweets without the following word"))
radioSizer1 = wx.StaticBoxSizer(staticbox, wx.HORIZONTAL)
radioSizer1.Add(self.contains, 0, wx.ALL, 5)
radioSizer1.Add(self.doesnt_contain, 0, wx.ALL, 5)
sizer.Add(radioSizer1, 0, wx.ALL, 5)
label = wx.StaticText(panel, -1, _(u"word"))
self.term = wx.TextCtrl(panel, -1, value)
dc = wx.WindowDC(self.term)
dc.SetFont(self.term.GetFont())
self.term.SetSize(dc.GetTextExtent("0"*40))
self.allow_rts = wx.CheckBox(panel, wx.ID_ANY, _(u"Allow retweets"))
self.allow_quotes = wx.CheckBox(panel, wx.ID_ANY, _(u"Allow quoted tweets"))
self.allow_replies = wx.CheckBox(panel, wx.ID_ANY, _(u"Allow replies"))
self.allow_rts.SetValue(True)
self.allow_quotes.SetValue(True)
self.allow_replies.SetValue(True)
bsizer = wx.BoxSizer(wx.HORIZONTAL)
bsizer.Add(label, 0, wx.ALL, 5)
bsizer.Add(self.term, 0, wx.ALL, 5)
sizer.Add(bsizer, 0, wx.ALL, 5)
self.regexp = wx.CheckBox(panel, wx.ID_ANY, _(u"Use this term as a regular expression"))
sizer.Add(self.regexp, 0, wx.ALL, 5)
staticbox = wx.StaticBox(panel, label=_(u"Filter by language"))
self.load_language = wx.RadioButton(panel, -1, _(u"Load tweets in the following languages"), style=wx.RB_GROUP)
self.ignore_language = wx.RadioButton(panel, -1, _(u"Ignore tweets in the following languages"))
self.skip_language_filtering = wx.RadioButton(panel, -1, _(u"Don't filter by language"))
self.skip_language_filtering.SetValue(True)
widgetUtils.connect_event(self.load_language, widgetUtils.RADIOBUTTON, self.show_language_options)
widgetUtils.connect_event(self.ignore_language, widgetUtils.RADIOBUTTON, self.show_language_options)
widgetUtils.connect_event(self.skip_language_filtering, widgetUtils.RADIOBUTTON, self.hide_language_options)
radioSizer2 = wx.StaticBoxSizer(staticbox, wx.HORIZONTAL)
radioSizer2.Add(self.load_language, 0, wx.ALL, 5)
radioSizer2.Add(self.ignore_language, 0, wx.ALL, 5)
radioSizer2.Add(self.skip_language_filtering, 0, wx.ALL, 5)
sizer.Add(radioSizer2, 0, wx.ALL, 5)
self.indexes = []
langsLabel = wx.StaticText(panel, -1, _(u"Supported languages"))
self.cb = wx.ComboBox(panel, -1, choices=languages, value=languages[0])
langsSizer = wx.BoxSizer()
langsSizer.Add(langsLabel, 0, wx.ALL, 5)
langsSizer.Add(self.cb, 0, wx.ALL, 5)
self.add = wx.Button(panel, wx.ID_ANY, _(u"Add selected language to filter"))
self.add.Bind(wx.EVT_BUTTON, self.add_lang)
langsSizer.Add(self.add, 0, wx.ALL, 5)
sizer.Add(langsSizer, 0, wx.ALL, 5)
lbl = wx.StaticText(panel, wx.ID_ANY, _(u"Selected languages"))
self.langs = wx.ListBox(panel, -1)
self.remove = wx.Button(panel, wx.ID_ANY, _(u"Remove"))
self.remove.Bind(wx.EVT_BUTTON, self.remove_lang)
selectionSizer = wx.BoxSizer(wx.HORIZONTAL)
selectionSizer.Add(lbl, 0, wx.ALL, 5)
selectionSizer.Add(self.langs, 0, wx.ALL, 5)
selectionSizer.Add(self.remove, 0, wx.ALL, 5)
sizer.Add(selectionSizer, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
ok.SetDefault()
ok.Bind(wx.EVT_BUTTON, self.validate_title)
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Cancel"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5)
btnsizer.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.hide_language_options()
self.SetClientSize(sizer.CalcMin())
def get_lang(self):
return self.cb.GetValue()
def add_lang(self, *args, **kwargs):
selection = self.get_lang()
if selection in self.langs_list:
self.langs.Append(selection)
self.indexes.append(selection)
def remove_lang(self, *args, **kwargs):
n = self.langs.GetSelection()
v = self.langs.GetStringSelection()
self.langs.Delete(n)
self.indexes.remove(v)
def get_selected_langs(self):
return self.indexes
def hide_language_options(self, *args, **kwargs):
for i in [self.cb, self.add, self.langs, self.remove]:
i.Hide()
def show_language_options(self, *args, **kwargs):
for i in [self.cb, self.add, self.langs, self.remove]:
i.Show()
def validate_title(self, *args, **kwargs):
if self.title.GetValue() == "" or self.title.GetValue() == None:
return wx.MessageDialog(self, _("You must define a name for the filter before creating it."), _("Missing filter name"), wx.ICON_ERROR).ShowModal()
self.EndModal(wx.ID_OK)
class filterManagerDialog(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(filterManagerDialog, self).__init__(parent=None, *args, **kwargs)
self.SetTitle(_(u"Manage filters"))
panel = wx.Panel(self)
label = wx.StaticText(panel, -1, _(u"Filters"))
self.filters = widgets.list(panel, _(u"Filter"), _(u"Buffer"), _(u"Filter by word"), _(u"Filter by language"), size=(800, 800), style=wx.LC_REPORT|wx.LC_SINGLE_SEL)
self.filters.list.SetFocus()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(label)
sizer.Add(self.filters.list)
self.edit = wx.Button(panel, wx.ID_ANY, _(u"Edit"))
self.edit.Enable(False)
self.delete = wx.Button(panel, wx.ID_ANY, _(u"Remove"))
self.cancel = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer()
btnSizer.Add(self.edit, 0, wx.ALL, 5)
btnSizer.Add(self.delete, 0, wx.ALL, 5)
btnSizer.Add(self.cancel, 0, wx.ALL, 5)
sizer.Add(btnSizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
def get_item(self):
return self.filters.get_selected()
def clear(self):
self.filters.clear()

View File

@@ -1,150 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import wx
import widgetUtils
from multiplatform_widgets import widgets
class listViewer(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(listViewer, self).__init__(parent=None, *args, **kwargs)
self.SetTitle(_(u"Lists manager"))
panel = wx.Panel(self)
label = wx.StaticText(panel, -1, _(u"Lists"))
self.lista = widgets.list(panel, _(u"List"), _(u"Description"), _(u"Owner"), _(u"Members"), _(u"mode"), size=(800, 800), style=wx.LC_REPORT|wx.LC_SINGLE_SEL)
self.lista.list.SetFocus()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(label)
sizer.Add(self.lista.list)
self.createBtn = wx.Button(panel, wx.ID_ANY, _(u"Create a new list"))
self.editBtn = wx.Button(panel, -1, _(u"Edit"))
self.deleteBtn = wx.Button(panel, -1, _(u"Remove"))
self.view = wx.Button(panel, -1, _(u"Open in buffer"))
# self.members = wx.Button(panel, -1, _(u"View members"))
# self.members.Disable()
# self.subscriptors = wx.Button(panel, -1, _(u"View subscribers"))
# self.subscriptors.Disable()
# self.get_linkBtn = wx.Button(panel, -1, _(u"Get link for the list"))
# self.get_linkBtn.Bind(wx.EVT_BUTTON, self.onGetLink)
self.cancelBtn = wx.Button(panel, wx.ID_CANCEL)
btnSizer = wx.BoxSizer()
btnSizer.Add(self.createBtn)
btnSizer.Add(self.editBtn)
btnSizer.Add(self.cancelBtn)
panel.SetSizer(sizer)
def populate_list(self, lists, clear=False):
if clear == True:
self.clear()
for item in lists:
self.lista.insert_item(False, *item)
def get_item(self):
return self.lista.get_selected()
def clear(self):
self.lista.clear()
class userListViewer(listViewer):
def __init__(self, username, *args, **kwargs):
self.username = username
super(userListViewer, self).__init__(*args, **kwargs)
self.SetTitle(_(u"Viewing lists for %s") % (self.username))
self.createBtn.SetLabel(_(u"Subscribe"))
self.deleteBtn.SetLabel(_(u"Unsubscribe"))
self.editBtn.Disable()
self.view.Disable()
class createListDialog(widgetUtils.BaseDialog):
def __init__(self, *args, **kwargs):
super(createListDialog, self).__init__(parent=None, *args, **kwargs)
self.SetTitle(_(u"Create a new list"))
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
name = wx.StaticText(panel, -1, _(u"Name (20 characters maximun)"))
self.name = wx.TextCtrl(panel, -1)
nameSizer = wx.BoxSizer(wx.HORIZONTAL)
nameSizer.Add(name)
nameSizer.Add(self.name)
description = wx.StaticText(panel, -1, _(u"Description"))
self.description = wx.TextCtrl(panel, -1)
descriptionSizer = wx.BoxSizer(wx.HORIZONTAL)
descriptionSizer.Add(description)
descriptionSizer.Add(self.description)
mode = wx.StaticText(panel, -1, _(u"Mode"))
self.public = wx.RadioButton(panel, -1, _(u"Public"), style=wx.RB_GROUP)
self.private = wx.RadioButton(panel, -1, _(u"Private"))
modeBox = wx.BoxSizer(wx.HORIZONTAL)
modeBox.Add(mode)
modeBox.Add(self.public)
modeBox.Add(self.private)
ok = wx.Button(panel, wx.ID_OK)
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL)
btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(ok)
btnBox.Add(cancel)
sizer.Add(nameSizer)
sizer.Add(descriptionSizer)
sizer.Add(modeBox)
sizer.Add(btnBox)
class editListDialog(createListDialog):
def __init__(self, list, *args, **kwargs):
super(editListDialog, self).__init__(*args, **kwargs)
self.SetTitle(_(u"Editing the list %s") % (list.name))
self.name.ChangeValue(list.name)
self.description.ChangeValue(list.description)
if list.mode == "public":
self.public.SetValue(True)
else:
self.private.SetValue(True)
class addUserListDialog(listViewer):
def __init__(self, *args, **kwargs):
super(addUserListDialog, self).__init__(*args, **kwargs)
self.SetTitle(_(u"Select a list to add the user"))
self.createBtn.SetLabel(_(u"Add"))
self.createBtn.SetDefault()
self.createBtn.Bind(wx.EVT_BUTTON, self.ok)
self.editBtn.Disable()
self.view.Disable()
# self.subscriptors.Disable()
# self.members.Disable()
self.deleteBtn.Disable()
widgetUtils.connect_event(self.lista.list, widgetUtils.KEYPRESS, self.on_keypress)
def on_keypress(self, event):
"""Catch return and execute ok()"""
if event.GetKeyCode() == wx.WXK_RETURN:
return self.ok()
event.Skip()
def ok(self, *args, **kwargs):
self.EndModal(wx.ID_OK)
class removeUserListDialog(listViewer):
def __init__(self, *args, **kwargs):
super(removeUserListDialog, self).__init__(*args, **kwargs)
self.SetTitle(_(u"Select a list to remove the user"))
self.createBtn.SetLabel(_(u"Remove"))
self.createBtn.SetDefault()
self.createBtn.SetId(wx.ID_OK)
self.editBtn.Disable()
self.view.Disable()
# self.subscriptors.Disable()
# self.members.Disable()
self.deleteBtn.Disable()
widgetUtils.connect_event(self.lista.list, widgetUtils.KEYPRESS, self.on_keypress)
def on_keypress(self, event):
"""Catch return and execute EndModal()"""
if event.GetKeyCode() == wx.WXK_RETURN:
return self.EndModal(wx.ID_OK)
event.Skip()
def remove_list():
return wx.MessageDialog(None, _("Do you really want to delete this list?"), _("Delete"), wx.YES_NO).ShowModal()

View File

@@ -0,0 +1,7 @@
ffmpeg -hwaccel qsv -c:v h264_qsv -i "$1" -map 0 -c copy -c:v hevc_qsv -preset slow -global_quality 22 -look_ahead 1 "final/${1%.*}.mkv"
#!/bin/bash
for i in *.wmv;
do
ffmpeg -i "$i" -c:v libx264 -c:a aac -vf scale=640:480 -crf 20 "final/$i.mp4"
done

View File

@@ -1,73 +0,0 @@
# -*- coding: utf-8 -*-
import widgetUtils
from . import baseDialog
import wx
from extra import translator
class searchDialog(baseDialog.BaseWXDialog):
def __init__(self, value=""):
super(searchDialog, self).__init__(None, -1)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetTitle(_(u"Search on Twitter"))
label = wx.StaticText(panel, -1, _(u"&Search"))
self.term = wx.TextCtrl(panel, -1, value)
self.term.SetFocus()
dc = wx.WindowDC(self.term)
dc.SetFont(self.term.GetFont())
self.term.SetSize(dc.GetTextExtent("0"*40))
sizer.Add(label, 0, wx.ALL, 5)
sizer.Add(self.term, 0, wx.ALL, 5)
self.tweets = wx.RadioButton(panel, -1, _(u"Tweets"), style=wx.RB_GROUP)
self.users = wx.RadioButton(panel, -1, _(u"Users"))
widgetUtils.connect_event(self.tweets, widgetUtils.RADIOBUTTON, self.show_advanced_search)
widgetUtils.connect_event(self.users, widgetUtils.RADIOBUTTON, self.hide_advanced_search)
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
radioSizer.Add(self.tweets, 0, wx.ALL, 5)
radioSizer.Add(self.users, 0, wx.ALL, 5)
sizer.Add(radioSizer, 0, wx.ALL, 5)
lang = wx.StaticText(panel, -1, _(u"&Language for results: "))
langs = [x for x in list(translator.translator.languages.values())]
langs.insert(0, _(u"any"))
self.lang = wx.ComboBox(panel, -1, choices=langs, value=langs[0], style = wx.CB_READONLY)
langBox = wx.BoxSizer(wx.HORIZONTAL)
langBox.Add(lang, 0, wx.ALL, 5)
langBox.Add(self.lang, 0, wx.ALL, 5)
sizer.Add(langBox, 0, wx.ALL, 5)
resulttype = wx.StaticText(panel, -1, _(U"Results &type: "))
self.resultstype = wx.ComboBox(panel, -1, choices=[_(u"Mixed"), _(u"Recent"), _(u"Popular")], value=_(u"Mixed"), style=wx.CB_READONLY)
rBox = wx.BoxSizer(wx.HORIZONTAL)
rBox.Add(resulttype, 0, wx.ALL, 5)
rBox.Add(self.resultstype, 0, wx.ALL, 5)
sizer.Add(rBox, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5)
btnsizer.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_language(self):
l = self.lang.GetStringSelection()
if l == _(u"any"):
return ""
for langcode, langname in translator.translator.languages.items():
if langname == l:
return langcode
def get_result_type(self):
r = self.resultstype.GetValue()
if r == _(u"Mixed"): return "mixed"
elif r == _(u"Recent"): return "recent"
elif r == _(u"Popular"): return "popular"
def hide_advanced_search(self, *args, **kwargs):
self.lang.Hide()
self.resultstype.Hide()
def show_advanced_search(self, *args, **kwargs):
self.lang.Show()
self.resultstype.Show()

View File

@@ -1,28 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import wx
from . import baseDialog
class showUserProfile(baseDialog.BaseWXDialog):
def __init__(self):
super(showUserProfile, self).__init__(parent=None, id=wx.ID_ANY)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
static = wx.StaticText(panel, -1, _(u"Details"))
sizer.Add(static, 0, wx.ALL, 5)
self.text = wx.TextCtrl(panel, -1, style=wx.TE_MULTILINE|wx.TE_READONLY, size=(350, 250))
self.text.SetFocus()
sizer.Add(self.text, 0, wx.ALL|wx.EXPAND, 5)
self.url = wx.Button(panel, -1, _(u"&Go to URL"), size=wx.DefaultSize)
self.url.Disable()
close = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnSizer = wx.BoxSizer(wx.HORIZONTAL)
btnSizer.Add(self.url, 0, wx.ALL, 5)
btnSizer.Add(close, 0, wx.ALL, 5)
sizer.Add(btnSizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def enable_url(self, enabled=True):
self.url.Enable(enabled)

View File

@@ -1,45 +0,0 @@
# -*- coding: utf-8 -*-
from . import baseDialog
import wx
class trendingTopicsDialog(baseDialog.BaseWXDialog):
def __init__(self):
super(trendingTopicsDialog, self).__init__(None, -1)
panel = wx.Panel(self)
sizer = wx.BoxSizer(wx.VERTICAL)
self.SetTitle(_(u"View trending topics"))
label = wx.StaticText(panel, wx.NewId(), _(u"Trending topics by"))
self.country = wx.RadioButton(panel, -1, _(u"Country"), style=wx.RB_GROUP)
self.city = wx.RadioButton(panel, -1, _(u"City"))
radioSizer = wx.BoxSizer(wx.HORIZONTAL)
radioSizer.Add(label, 0, wx.ALL, 5)
radioSizer.Add(self.country, 0, wx.ALL, 5)
radioSizer.Add(self.city, 0, wx.ALL, 5)
sizer.Add(radioSizer, 0, wx.ALL, 5)
label = wx.StaticText(panel, -1, _(u"&Location"))
self.location = wx.ListBox(panel, -1, choices=[], style=wx.CB_READONLY)
locationBox = wx.BoxSizer(wx.HORIZONTAL)
locationBox.Add(label, 0, wx.ALL, 5)
locationBox.Add(self.location, 0, wx.ALL, 5)
sizer.Add(locationBox, 0, wx.ALL, 5)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5)
btnsizer.Add(cancel, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_active(self):
if self.country.GetValue() == True:
return "country"
else:
return "city"
def get_item(self):
return self.location.GetStringSelection()
def set(self, values):
self.location.Set(values)

View File

@@ -1,2 +0,0 @@
from .tweetDialogs import tweet, reply, dm, viewTweet, viewNonTweet, poll
from .templateDialogs import EditTemplateDialog

View File

@@ -1,542 +0,0 @@
""" GUI dialogs for tweet writing and displaying. """
import wx
from typing import List
class tweet(wx.Dialog):
def __init__(self, title: str, caption: str, message: str = "", max_length: int = 280, thread_mode: bool = True, *args, **kwds) -> None:
""" Creates the basic Tweet dialog. This might be considered the base class for other dialogs.
title str: title to be used in the dialog.
caption str: This is the text to be placed alongside the text field.
message str: Text to be inserted in the tweet.
max_length int: Maximum amount of characters the tweet will accept. By default is 280 chahracters.
thread_mode bool: If set to False, disables the button that allows to make threads by adding more tweets.
"""
super(tweet, self).__init__(parent=None, *args, **kwds)
self.SetTitle(title)
self.create_controls(max_length=max_length, caption=caption, message=message, thread_mode=thread_mode)
def create_controls(self, message: str, caption: str, max_length: int, thread_mode: bool) -> None:
panel = wx.Panel(self)
mainBox = wx.BoxSizer(wx.VERTICAL)
text_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(text_sizer, 1, wx.EXPAND, 0)
label_1 = wx.StaticText(panel, wx.ID_ANY, caption)
text_sizer.Add(label_1, 0, 0, 0)
self.text = wx.TextCtrl(panel, wx.ID_ANY, "", size=(444, -1), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text)
text_sizer.Add(self.text, 1, wx.EXPAND, 0)
list_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(list_sizer, 1, wx.EXPAND, 0)
Attachment_sizer = wx.BoxSizer(wx.VERTICAL)
list_sizer.Add(Attachment_sizer, 1, wx.EXPAND, 0)
label_2 = wx.StaticText(panel, wx.ID_ANY, _("Attachments"))
Attachment_sizer.Add(label_2, 0, 0, 0)
self.attachments = wx.ListCtrl(panel, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES)
self.attachments.AppendColumn(_("File"))
self.attachments.AppendColumn(_("Type"))
self.attachments.AppendColumn(_("Description"))
Attachment_sizer.Add(self.attachments, 1, wx.EXPAND, 0)
self.remove_attachment = wx.Button(panel, wx.ID_ANY, _("Delete attachment"))
self.remove_attachment.Enable(False)
Attachment_sizer.Add(self.remove_attachment, 0, 0, 0)
tweet_sizer = wx.BoxSizer(wx.VERTICAL)
list_sizer.Add(tweet_sizer, 1, wx.EXPAND, 0)
label_3 = wx.StaticText(panel, wx.ID_ANY, _("Added Tweets"))
tweet_sizer.Add(label_3, 0, 0, 0)
self.tweets = wx.ListCtrl(panel, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES)
self.tweets.AppendColumn(_("Text"))
self.tweets.AppendColumn(_("Attachments"))
self.tweets.Enable(False)
tweet_sizer.Add(self.tweets, 1, wx.EXPAND, 0)
self.remove_tweet = wx.Button(panel, wx.ID_ANY, _("Delete tweet"))
self.remove_tweet.Enable(False)
tweet_sizer.Add(self.remove_tweet, 0, 0, 0)
btn_sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_1, 1, wx.EXPAND, 0)
self.add = wx.Button(panel, wx.ID_ANY, _("A&dd..."))
btn_sizer_1.Add(self.add, 0, 0, 0)
self.add_tweet = wx.Button(panel, wx.ID_ANY, _("Add t&weet"))
self.add_tweet.Enable(thread_mode)
btn_sizer_1.Add(self.add_tweet, 0, 0, 0)
self.add_audio = wx.Button(panel, wx.ID_ANY, _("&Attach audio..."))
btn_sizer_1.Add(self.add_audio, 0, 0, 0)
btn_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_2, 1, wx.EXPAND, 0)
self.autocomplete_users = wx.Button(panel, wx.ID_ANY, _("Auto&complete users"))
btn_sizer_2.Add(self.autocomplete_users, 0, 0, 0)
self.spellcheck = wx.Button(panel, wx.ID_ANY, _("Check &spelling..."))
btn_sizer_2.Add(self.spellcheck, 0, 0, 0)
self.translate = wx.Button(panel, wx.ID_ANY, _("&Translate"))
btn_sizer_2.Add(self.translate, 0, 0, 0)
ok_cancel_sizer = wx.StdDialogButtonSizer()
mainBox.Add(ok_cancel_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.send = wx.Button(panel, wx.ID_OK, _("Sen&d"))
self.send.SetDefault()
ok_cancel_sizer.Add(self.send, 0, 0, 0)
self.cancel = wx.Button(panel, wx.ID_CANCEL, "")
ok_cancel_sizer.AddButton(self.cancel)
ok_cancel_sizer.Realize()
panel.SetSizer(mainBox)
self.Fit()
self.SetAffirmativeId(self.send.GetId())
self.SetEscapeId(self.cancel.GetId())
self.Layout()
def handle_keys(self, event: wx.Event, *args, **kwargs) -> None:
""" Allows to react to certain keyboard events from the text control. """
shift=event.ShiftDown()
if event.GetKeyCode() == wx.WXK_RETURN and shift==False and hasattr(self,'send'):
self.EndModal(wx.ID_OK)
else:
event.Skip()
def reset_controls(self) -> None:
""" Resetss text control and attachments to their default, empty values. This is used while adding more tweets in a thread. """
self.text.ChangeValue("")
self.attachments.DeleteAllItems()
def add_item(self, list_type: str = "attachment", item: List[str] = []) -> None:
""" Adds an item to a list control. Item should be a list with the same amount of items for each column present in the ListCtrl. """
if list_type == "attachment":
self.attachments.Append(item)
else:
self.tweets.Append(item)
def remove_item(self, list_type: str = "attachment") -> None:
if list_type == "attachment":
item = self.attachments.GetFocusedItem()
if item > -1:
self.attachments.DeleteItem(item)
else:
item = self.tweets.GetFocusedItem()
if item > -1:
self.tweets.DeleteItem(item)
def attach_menu(self, event=None, enabled=True, *args, **kwargs):
menu = wx.Menu()
self.add_image = menu.Append(wx.ID_ANY, _("Image"))
self.add_image.Enable(enabled)
self.add_video = menu.Append(wx.ID_ANY, _("Video"))
self.add_video.Enable(enabled)
self.add_poll = menu.Append(wx.ID_ANY, _("Poll"))
self.add_poll.Enable(enabled)
return menu
def ask_description(self):
dlg = wx.TextEntryDialog(self, _(u"please provide a description"), _(u"Description"))
dlg.ShowModal()
result = dlg.GetValue()
dlg.Destroy()
return result
def get_image(self):
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return (None, None)
dsc = self.ask_description()
return (openFileDialog.GetPath(), dsc)
def get_video(self):
openFileDialog = wx.FileDialog(self, _("Select the video to be uploaded"), "", "", _("Video files (*.mp4)|*.mp4"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
def unable_to_attach_file(self, *args, **kwargs):
return wx.MessageDialog(self, _("It is not possible to add more attachments. Please make sure your tweet complies with Twitter'S attachment rules. You can add only one video or GIF in every tweet, and a maximum of 4 photos."), _("Error adding attachment"), wx.ICON_ERROR).ShowModal()
class reply(tweet):
def __init__(self, users: List[str] = [], *args, **kwargs) -> None:
self.users = users
super(reply, self).__init__(*args, **kwargs)
def create_controls(self, message: str, caption: str, max_length: int, thread_mode: bool) -> None:
panel = wx.Panel(self)
mainBox = wx.BoxSizer(wx.VERTICAL)
text_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(text_sizer, 1, wx.EXPAND, 0)
label_1 = wx.StaticText(panel, wx.ID_ANY, caption)
text_sizer.Add(label_1, 0, 0, 0)
self.text = wx.TextCtrl(panel, wx.ID_ANY, "", size=(500, 200), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text)
text_sizer.Add(self.text, 1, wx.EXPAND, 0)
list_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(list_sizer, 1, wx.EXPAND, 0)
Attachment_sizer = wx.BoxSizer(wx.VERTICAL)
list_sizer.Add(Attachment_sizer, 1, wx.EXPAND, 0)
label_2 = wx.StaticText(panel, wx.ID_ANY, _("Attachments"))
Attachment_sizer.Add(label_2, 0, 0, 0)
self.attachments = wx.ListCtrl(panel, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES)
self.attachments.AppendColumn(_("File"))
self.attachments.AppendColumn(_("Type"))
self.attachments.AppendColumn(_("Description"))
Attachment_sizer.Add(self.attachments, 1, wx.EXPAND, 0)
self.remove_attachment = wx.Button(panel, wx.ID_ANY, _("Delete attachment"))
self.remove_attachment.Enable(False)
Attachment_sizer.Add(self.remove_attachment, 0, 0, 0)
user_sizer = wx.BoxSizer(wx.VERTICAL)
list_sizer.Add(user_sizer, 0, 0, 0)
self.mention_all = wx.CheckBox(panel, -1, _(u"&Mention to all"), size=wx.DefaultSize)
self.mention_all.Disable()
user_sizer.Add(self.mention_all, 0, wx.ALL, 5)
self.checkboxes = []
for i in self.users:
user_checkbox = wx.CheckBox(panel, -1, "@"+i, size=wx.DefaultSize)
self.checkboxes.append(user_checkbox)
user_sizer.Add(self.checkboxes[-1], 0, wx.ALL, 5)
btn_sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_1, 1, wx.EXPAND, 0)
self.add = wx.Button(panel, wx.ID_ANY, _("A&dd..."))
btn_sizer_1.Add(self.add, 0, 0, 0)
self.add_audio = wx.Button(panel, wx.ID_ANY, _("&Attach audio..."))
btn_sizer_1.Add(self.add_audio, 0, 0, 0)
btn_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_2, 1, wx.EXPAND, 0)
self.autocomplete_users = wx.Button(panel, wx.ID_ANY, _("Auto&complete users"))
btn_sizer_2.Add(self.autocomplete_users, 0, 0, 0)
self.spellcheck = wx.Button(panel, wx.ID_ANY, _("Check &spelling..."))
btn_sizer_2.Add(self.spellcheck, 0, 0, 0)
self.translate = wx.Button(panel, wx.ID_ANY, _("&Translate"))
btn_sizer_2.Add(self.translate, 0, 0, 0)
ok_cancel_sizer = wx.StdDialogButtonSizer()
mainBox.Add(ok_cancel_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.send = wx.Button(panel, wx.ID_OK, _("Sen&d"))
self.send.SetDefault()
ok_cancel_sizer.Add(self.send, 0, 0, 0)
self.cancel = wx.Button(panel, wx.ID_CANCEL, "")
ok_cancel_sizer.AddButton(self.cancel)
ok_cancel_sizer.Realize()
panel.SetSizer(mainBox)
self.Fit()
self.SetAffirmativeId(self.send.GetId())
self.SetEscapeId(self.cancel.GetId())
self.Layout()
def attach_menu(self, event=None, enabled=True, *args, **kwargs):
menu = wx.Menu()
self.add_image = menu.Append(wx.ID_ANY, _("Image"))
self.add_image.Enable(enabled)
self.add_video = menu.Append(wx.ID_ANY, _("Video"))
self.add_video.Enable(enabled)
return menu
class dm(tweet):
def __init__(self, users: List[str] = [], *args, **kwargs) -> None:
self.users = users
super(dm, self).__init__(*args, **kwargs)
def create_controls(self, message: str, caption: str, max_length: int, thread_mode: bool) -> None:
panel = wx.Panel(self)
mainBox = wx.BoxSizer(wx.VERTICAL)
label_recipient = wx.StaticText(panel, -1, _("&Recipient"))
self.cb = wx.ComboBox(panel, -1, choices=self.users, value=self.users[0], size=wx.DefaultSize)
self.autocomplete_users = wx.Button(panel, -1, _(u"Auto&complete users"))
recipient_sizer = wx.BoxSizer(wx.HORIZONTAL)
recipient_sizer.Add(label_recipient, 0, 0, 0)
recipient_sizer.Add(self.cb, 1, wx.EXPAND, 0)
mainBox.Add(recipient_sizer, 0, wx.EXPAND, 0)
text_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(text_sizer, 1, wx.EXPAND, 0)
label_1 = wx.StaticText(panel, wx.ID_ANY, caption)
text_sizer.Add(label_1, 0, 0, 0)
self.text = wx.TextCtrl(panel, wx.ID_ANY, "", size=(500, 200), style=wx.TE_MULTILINE|wx.TE_PROCESS_ENTER)
self.Bind(wx.EVT_CHAR_HOOK, self.handle_keys, self.text)
self.text.SetFocus()
text_sizer.Add(self.text, 1, wx.EXPAND, 0)
list_sizer = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(list_sizer, 1, wx.EXPAND, 0)
Attachment_sizer = wx.BoxSizer(wx.VERTICAL)
list_sizer.Add(Attachment_sizer, 1, wx.EXPAND, 0)
label_2 = wx.StaticText(panel, wx.ID_ANY, _("Attachments"))
Attachment_sizer.Add(label_2, 0, 0, 0)
self.attachments = wx.ListCtrl(panel, wx.ID_ANY, style=wx.BORDER_SUNKEN | wx.LC_HRULES | wx.LC_REPORT | wx.LC_SINGLE_SEL | wx.LC_VRULES)
self.attachments.AppendColumn(_("File"))
self.attachments.AppendColumn(_("Type"))
self.attachments.AppendColumn(_("Description"))
Attachment_sizer.Add(self.attachments, 1, wx.EXPAND, 0)
self.remove_attachment = wx.Button(panel, wx.ID_ANY, _("Delete attachment"))
self.remove_attachment.Enable(False)
Attachment_sizer.Add(self.remove_attachment, 0, 0, 0)
btn_sizer_1 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_1, 1, wx.EXPAND, 0)
self.add = wx.Button(panel, wx.ID_ANY, _("A&dd..."))
btn_sizer_1.Add(self.add, 0, 0, 0)
self.add_audio = wx.Button(panel, wx.ID_ANY, _("&Attach audio..."))
btn_sizer_1.Add(self.add_audio, 0, 0, 0)
btn_sizer_2 = wx.BoxSizer(wx.HORIZONTAL)
mainBox.Add(btn_sizer_2, 1, wx.EXPAND, 0)
self.spellcheck = wx.Button(panel, wx.ID_ANY, _("Check &spelling..."))
btn_sizer_2.Add(self.spellcheck, 0, 0, 0)
self.translate = wx.Button(panel, wx.ID_ANY, _("&Translate"))
btn_sizer_2.Add(self.translate, 0, 0, 0)
ok_cancel_sizer = wx.StdDialogButtonSizer()
mainBox.Add(ok_cancel_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.send = wx.Button(panel, wx.ID_OK, _("Sen&d"))
self.send.SetDefault()
ok_cancel_sizer.Add(self.send, 0, 0, 0)
self.cancel = wx.Button(panel, wx.ID_CANCEL, "")
ok_cancel_sizer.AddButton(self.cancel)
ok_cancel_sizer.Realize()
panel.SetSizer(mainBox)
self.Fit()
self.SetAffirmativeId(self.send.GetId())
self.SetEscapeId(self.cancel.GetId())
self.Layout()
def get_image(self):
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return (None, None)
return (openFileDialog.GetPath(), "")
def attach_menu(self, event=None, enabled=True, *args, **kwargs):
menu = wx.Menu()
self.add_image = menu.Append(wx.ID_ANY, _("Image"))
self.add_image.Enable(enabled)
self.add_video = menu.Append(wx.ID_ANY, _("Video"))
self.add_video.Enable(enabled)
return menu
class viewTweet(wx.Dialog):
def set_title(self, lenght):
self.SetTitle(_(u"Tweet - %i characters ") % (lenght,))
def __init__(self, text, rt_count, favs_count, source, date="", *args, **kwargs):
super(viewTweet, self).__init__(None, size=(850,850))
panel = wx.Panel(self)
label = wx.StaticText(panel, -1, _(u"Tweet"))
self.text = wx.TextCtrl(panel, -1, text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
dc = wx.WindowDC(self.text)
dc.SetFont(self.text.GetFont())
(x, y) = dc.GetMultiLineTextExtent("W"*280)
self.text.SetSize((x, y))
self.text.SetFocus()
textBox = wx.BoxSizer(wx.HORIZONTAL)
textBox.Add(label, 0, wx.ALL, 5)
textBox.Add(self.text, 1, wx.EXPAND, 5)
mainBox = wx.BoxSizer(wx.VERTICAL)
mainBox.Add(textBox, 0, wx.ALL, 5)
label2 = wx.StaticText(panel, -1, _(u"Image description"))
self.image_description = wx.TextCtrl(panel, -1, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
dc = wx.WindowDC(self.image_description)
dc.SetFont(self.image_description.GetFont())
(x, y) = dc.GetMultiLineTextExtent("0"*450)
self.image_description.SetSize((x, y))
self.image_description.Enable(False)
iBox = wx.BoxSizer(wx.HORIZONTAL)
iBox.Add(label2, 0, wx.ALL, 5)
iBox.Add(self.image_description, 1, wx.EXPAND, 5)
mainBox.Add(iBox, 0, wx.ALL, 5)
rtCountLabel = wx.StaticText(panel, -1, _(u"Retweets: "))
rtCount = wx.TextCtrl(panel, -1, rt_count, size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
rtBox = wx.BoxSizer(wx.HORIZONTAL)
rtBox.Add(rtCountLabel, 0, wx.ALL, 5)
rtBox.Add(rtCount, 0, wx.ALL, 5)
favsCountLabel = wx.StaticText(panel, -1, _(u"Likes: "))
favsCount = wx.TextCtrl(panel, -1, favs_count, size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
favsBox = wx.BoxSizer(wx.HORIZONTAL)
favsBox.Add(favsCountLabel, 0, wx.ALL, 5)
favsBox.Add(favsCount, 0, wx.ALL, 5)
sourceLabel = wx.StaticText(panel, -1, _(u"Source: "))
sourceTweet = wx.TextCtrl(panel, -1, source, size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
sourceBox = wx.BoxSizer(wx.HORIZONTAL)
sourceBox.Add(sourceLabel, 0, wx.ALL, 5)
sourceBox.Add(sourceTweet, 0, wx.ALL, 5)
dateLabel = wx.StaticText(panel, -1, _(u"Date: "))
dateTweet = wx.TextCtrl(panel, -1, date, size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
dc = wx.WindowDC(dateTweet)
dc.SetFont(dateTweet.GetFont())
(x, y) = dc.GetTextExtent("0"*100)
dateTweet.SetSize((x, y))
dateBox = wx.BoxSizer(wx.HORIZONTAL)
dateBox.Add(dateLabel, 0, wx.ALL, 5)
dateBox.Add(dateTweet, 0, wx.ALL, 5)
infoBox = wx.BoxSizer(wx.HORIZONTAL)
infoBox.Add(rtBox, 0, wx.ALL, 5)
infoBox.Add(favsBox, 0, wx.ALL, 5)
infoBox.Add(sourceBox, 0, wx.ALL, 5)
mainBox.Add(infoBox, 0, wx.ALL, 5)
mainBox.Add(dateBox, 0, wx.ALL, 5)
self.share = wx.Button(panel, wx.ID_ANY, _("Copy link to clipboard"))
self.share.Enable(False)
self.spellcheck = wx.Button(panel, -1, _("Check &spelling..."), size=wx.DefaultSize)
self.translateButton = wx.Button(panel, -1, _(u"&Translate..."), size=wx.DefaultSize)
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"C&lose"), size=wx.DefaultSize)
cancelButton.SetDefault()
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
buttonsBox.Add(self.share, 0, wx.ALL, 5)
buttonsBox.Add(self.spellcheck, 0, wx.ALL, 5)
buttonsBox.Add(self.translateButton, 0, wx.ALL, 5)
buttonsBox.Add(cancelButton, 0, wx.ALL, 5)
mainBox.Add(buttonsBox, 0, wx.ALL, 5)
selectId = wx.ID_ANY
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
self.accel_tbl = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('A'), selectId),
])
self.SetAcceleratorTable(self.accel_tbl)
panel.SetSizer(mainBox)
self.SetClientSize(mainBox.CalcMin())
def set_text(self, text):
self.text.ChangeValue(text)
def get_text(self):
return self.text.GetValue()
def set_image_description(self, desc):
self.image_description.Enable(True)
if len(self.image_description.GetValue()) == 0:
self.image_description.SetValue(desc)
else:
self.image_description.SetValue(self.image_description.GetValue()+"\n"+desc)
def text_focus(self):
self.text.SetFocus()
def onSelect(self, ev):
self.text.SelectAll()
def enable_button(self, buttonName):
if hasattr(self, buttonName):
return getattr(self, buttonName).Enable()
class viewNonTweet(wx.Dialog):
def __init__(self, text, date="", *args, **kwargs):
super(viewNonTweet, self).__init__(None, size=(850,850))
self.SetTitle(_(u"View"))
panel = wx.Panel(self)
label = wx.StaticText(panel, -1, _(u"Item"))
self.text = wx.TextCtrl(parent=panel, id=-1, value=text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
dc = wx.WindowDC(self.text)
dc.SetFont(self.text.GetFont())
(x, y) = dc.GetMultiLineTextExtent("0"*140)
self.text.SetSize((x, y))
self.text.SetFocus()
textBox = wx.BoxSizer(wx.HORIZONTAL)
textBox.Add(label, 0, wx.ALL, 5)
textBox.Add(self.text, 1, wx.EXPAND, 5)
mainBox = wx.BoxSizer(wx.VERTICAL)
mainBox.Add(textBox, 0, wx.ALL, 5)
if date != "":
dateLabel = wx.StaticText(panel, -1, _(u"Date: "))
date = wx.TextCtrl(panel, -1, date, size=wx.DefaultSize, style=wx.TE_READONLY|wx.TE_MULTILINE)
dc = wx.WindowDC(date)
dc.SetFont(date.GetFont())
(x, y) = dc.GetTextExtent("0"*100)
date.SetSize((x, y))
dateBox = wx.BoxSizer(wx.HORIZONTAL)
dateBox.Add(dateLabel, 0, wx.ALL, 5)
dateBox.Add(date, 0, wx.ALL, 5)
mainBox.Add(dateBox, 0, wx.ALL, 5)
self.share = wx.Button(panel, wx.ID_ANY, _("Copy link to clipboard"))
self.share.Enable(False)
self.spellcheck = wx.Button(panel, -1, _("Check &spelling..."), size=wx.DefaultSize)
self.unshortenButton = wx.Button(panel, -1, _(u"&Expand URL"), size=wx.DefaultSize)
self.unshortenButton.Disable()
self.translateButton = wx.Button(panel, -1, _(u"&Translate..."), size=wx.DefaultSize)
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"C&lose"), size=wx.DefaultSize)
cancelButton.SetDefault()
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
buttonsBox.Add(self.share, 0, wx.ALL, 5)
buttonsBox.Add(self.spellcheck, 0, wx.ALL, 5)
buttonsBox.Add(self.unshortenButton, 0, wx.ALL, 5)
buttonsBox.Add(self.translateButton, 0, wx.ALL, 5)
buttonsBox.Add(cancelButton, 0, wx.ALL, 5)
mainBox.Add(buttonsBox, 0, wx.ALL, 5)
selectId = wx.ID_ANY
self.Bind(wx.EVT_MENU, self.onSelect, id=selectId)
self.accel_tbl = wx.AcceleratorTable([
(wx.ACCEL_CTRL, ord('A'), selectId),
])
self.SetAcceleratorTable(self.accel_tbl)
panel.SetSizer(mainBox)
self.SetClientSize(mainBox.CalcMin())
def onSelect(self, ev):
self.text.SelectAll()
def set_text(self, text):
self.text.ChangeValue(text)
def get_text(self):
return self.text.GetValue()
def text_focus(self):
self.text.SetFocus()
def enable_button(self, buttonName):
if hasattr(self, buttonName):
return getattr(self, buttonName).Enable()
class poll(wx.Dialog):
def __init__(self, *args, **kwds):
super(poll, self).__init__(parent=None, id=wx.NewId(), title=_("Add a poll"))
sizer_1 = wx.BoxSizer(wx.VERTICAL)
period_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_1.Add(period_sizer, 1, wx.EXPAND, 0)
label_period = wx.StaticText(self, wx.ID_ANY, _("Participation time (in days)"))
period_sizer.Add(label_period, 0, 0, 0)
self.period = wx.SpinCtrl(self, wx.ID_ANY)
self.period.SetFocus()
self.period.SetRange(1, 7)
self.period.SetValue(7)
period_sizer.Add(self.period, 0, 0, 0)
sizer_2 = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, _("Choices")), wx.VERTICAL)
sizer_1.Add(sizer_2, 1, wx.EXPAND, 0)
option1_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_2.Add(option1_sizer, 1, wx.EXPAND, 0)
label_2 = wx.StaticText(self, wx.ID_ANY, _("Option 1"))
option1_sizer.Add(label_2, 0, 0, 0)
self.option1 = wx.TextCtrl(self, wx.ID_ANY, "")
self.option1.SetMaxLength(25)
option1_sizer.Add(self.option1, 0, 0, 0)
option2_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_2.Add(option2_sizer, 1, wx.EXPAND, 0)
label_3 = wx.StaticText(self, wx.ID_ANY, _("Option 2"))
option2_sizer.Add(label_3, 0, 0, 0)
self.option2 = wx.TextCtrl(self, wx.ID_ANY, "")
self.option2.SetMaxLength(25)
option2_sizer.Add(self.option2, 0, 0, 0)
option3_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_2.Add(option3_sizer, 1, wx.EXPAND, 0)
label_4 = wx.StaticText(self, wx.ID_ANY, _("Option 3"))
option3_sizer.Add(label_4, 0, 0, 0)
self.option3 = wx.TextCtrl(self, wx.ID_ANY, "")
self.option3.SetMaxLength(25)
option3_sizer.Add(self.option3, 0, 0, 0)
option4_sizer = wx.BoxSizer(wx.HORIZONTAL)
sizer_2.Add(option4_sizer, 1, wx.EXPAND, 0)
label_5 = wx.StaticText(self, wx.ID_ANY, _("Option 4"))
option4_sizer.Add(label_5, 0, 0, 0)
self.option4 = wx.TextCtrl(self, wx.ID_ANY, "")
self.option4.SetMaxLength(25)
option4_sizer.Add(self.option4, 0, 0, 0)
btn_sizer = wx.StdDialogButtonSizer()
sizer_1.Add(btn_sizer, 0, wx.ALIGN_RIGHT | wx.ALL, 4)
self.button_OK = wx.Button(self, wx.ID_OK)
self.button_OK.SetDefault()
self.button_OK.Bind(wx.EVT_BUTTON, self.validate_data)
btn_sizer.AddButton(self.button_OK)
self.button_CANCEL = wx.Button(self, wx.ID_CANCEL, "")
btn_sizer.AddButton(self.button_CANCEL)
btn_sizer.Realize()
self.SetSizer(sizer_1)
sizer_1.Fit(self)
self.SetAffirmativeId(self.button_OK.GetId())
self.SetEscapeId(self.button_CANCEL.GetId())
self.Layout()
def get_options(self):
controls = [self.option1, self.option2, self.option3, self.option4]
options = [option.GetValue() for option in controls if option.GetValue() != ""]
return options
def validate_data(self, *args, **kwargs):
options = self.get_options()
if len(options) < 2:
return wx.MessageDialog(self, _("Please make sure you have provided at least two options for the poll."), _("Not enough information"), wx.ICON_ERROR).ShowModal()
self.EndModal(wx.ID_OK)

View File

@@ -1,100 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from __future__ import unicode_literals
import wx
from . import baseDialog
class updateProfileDialog(baseDialog.BaseWXDialog):
def __init__(self):
super(updateProfileDialog, self).__init__(parent=None, id=-1)
self.SetTitle(_(u"Update your profile"))
panel = wx.Panel(self)
labelName = wx.StaticText(panel, -1, _(u"&Name (50 characters maximum)"))
self.name = wx.TextCtrl(panel, -1)
self.name.SetFocus()
dc = wx.WindowDC(self.name)
dc.SetFont(self.name.GetFont())
self.name.SetSize(dc.GetTextExtent("0"*50))
labelLocation = wx.StaticText(panel, -1, _(u"&Location"))
self.location = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.location)
dc.SetFont(self.location.GetFont())
self.location.SetSize(dc.GetTextExtent("0"*35))
labelUrl = wx.StaticText(panel, -1, _(u"&Website"))
self.url = wx.TextCtrl(panel, -1)
dc = wx.WindowDC(self.url)
dc.SetFont(self.url.GetFont())
self.url.SetSize(dc.GetTextExtent("0"*22))
labelDescription = wx.StaticText(panel, -1, _(u"&Bio (160 characters maximum)"))
self.description = wx.TextCtrl(panel, -1, size=(400, 400))
dc = wx.WindowDC(self.description)
dc.SetFont(self.description.GetFont())
self.description.SetSize(dc.GetTextExtent("0"*160))
self.image = None
self.upload_image = wx.Button(panel, -1, _(u"Upload a &picture"))
self.ok = wx.Button(panel, wx.ID_OK, _(u"&Update profile"))
self.ok.SetDefault()
close = wx.Button(panel, wx.ID_CANCEL, _("&Close"))
sizer = wx.BoxSizer(wx.VERTICAL)
nameBox = wx.BoxSizer(wx.HORIZONTAL)
nameBox.Add(labelName, 0, wx.ALL, 5)
nameBox.Add(self.name, 0, wx.ALL, 5)
sizer.Add(nameBox, 0, wx.ALL, 5)
locationBox = wx.BoxSizer(wx.HORIZONTAL)
locationBox.Add(labelLocation, 0, wx.ALL, 5)
locationBox.Add(self.location, 0, wx.ALL, 5)
sizer.Add(locationBox, 0, wx.ALL, 5)
urlBox = wx.BoxSizer(wx.HORIZONTAL)
urlBox.Add(labelUrl, 0, wx.ALL, 5)
urlBox.Add(self.url, 0, wx.ALL, 5)
sizer.Add(urlBox, 0, wx.ALL, 5)
descriptionBox = wx.BoxSizer(wx.HORIZONTAL)
descriptionBox.Add(labelDescription, 0, wx.ALL, 5)
descriptionBox.Add(self.description, 0, wx.ALL, 5)
sizer.Add(descriptionBox, 0, wx.ALL, 5)
sizer.Add(self.upload_image, 5, wx.CENTER, 5)
btnBox = wx.BoxSizer(wx.HORIZONTAL)
btnBox.Add(self.ok, 0, wx.ALL, 5)
btnBox.Add(close, 0, wx.ALL, 5)
sizer.Add(btnBox, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def set_name(self, name):
self.set("name", name)
def set_description(self, description):
self.set("description", description)
def set_location(self, location):
self.set("location", location)
def set_url(self, url):
self.set("url", url)
def change_upload_button(self, uploaded=False):
if uploaded == False:
self.upload_image.SetLabel(_(u"Upload a picture"))
else:
self.upload_image.SetLabel(_(u"Discard image"))
def upload_picture(self):
openFileDialog = wx.FileDialog(self, _(u"Select the picture to be uploaded"), "", "", _("Image files (*.png, *.jpg, *.gif)|*.png; *.jpg; *.gif"), wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)
if openFileDialog.ShowModal() == wx.ID_CANCEL:
return None
return openFileDialog.GetPath()
def hide_upload_button(self, hide):
self.upload_image.Enable(hide)
def set_readonly(self):
self.name.style = wx.TE_READONLY
self.name.Refresh()
self.description.style = wx.TE_READONLY
self.description.Refresh()
self.location.style = wx.TE_READONLY
self.location.Refresh()
self.url.style = wx.TE_READONLY
self.url.Refresh()
self.hide_upload_button(False)
self.ok.Enable(False)

View File

@@ -1,90 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import wx
class UserActionsDialog(wx.Dialog):
def __init__(self, users=[], default="follow", *args, **kwargs):
super(UserActionsDialog, self).__init__(parent=None, *args, **kwargs)
panel = wx.Panel(self)
userSizer = wx.BoxSizer()
self.SetTitle(_(u"Action"))
userLabel = wx.StaticText(panel, -1, _(u"&User"))
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
self.cb.SetFocus()
self.autocompletion = wx.Button(panel, -1, _(u"&Autocomplete users"))
userSizer.Add(userLabel, 0, wx.ALL, 5)
userSizer.Add(self.cb, 0, wx.ALL, 5)
userSizer.Add(self.autocompletion, 0, wx.ALL, 5)
actionSizer = wx.BoxSizer(wx.VERTICAL)
label2 = wx.StaticText(panel, -1, _(u"Action"))
self.follow = wx.RadioButton(panel, -1, _(u"&Follow"), name=_(u"Action"), style=wx.RB_GROUP)
self.unfollow = wx.RadioButton(panel, -1, _(u"U&nfollow"))
self.mute = wx.RadioButton(panel, -1, _(u"&Mute"))
self.unmute = wx.RadioButton(panel, -1, _(u"Unmu&te"))
self.block = wx.RadioButton(panel, -1, _(u"&Block"))
self.unblock = wx.RadioButton(panel, -1, _(u"Unbl&ock"))
self.reportSpam = wx.RadioButton(panel, -1, _(u"&Report as spam"))
self.ignore_client = wx.RadioButton(panel, -1, _(u"&Ignore tweets from this client"))
self.setup_default(default)
hSizer = wx.BoxSizer(wx.HORIZONTAL)
hSizer.Add(label2, 0, wx.ALL, 5)
actionSizer.Add(self.follow, 0, wx.ALL, 5)
actionSizer.Add(self.unfollow, 0, wx.ALL, 5)
actionSizer.Add(self.mute, 0, wx.ALL, 5)
actionSizer.Add(self.unmute, 0, wx.ALL, 5)
actionSizer.Add(self.block, 0, wx.ALL, 5)
actionSizer.Add(self.unblock, 0, wx.ALL, 5)
actionSizer.Add(self.reportSpam, 0, wx.ALL, 5)
actionSizer.Add(self.ignore_client, 0, wx.ALL, 5)
hSizer.Add(actionSizer, 0, wx.ALL, 5)
sizer = wx.BoxSizer(wx.VERTICAL)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok)
btnsizer.Add(cancel)
sizer.Add(userSizer)
sizer.Add(hSizer, 0, wx.ALL, 5)
sizer.Add(btnsizer)
panel.SetSizer(sizer)
def get_action(self):
if self.follow.GetValue() == True: return "follow"
elif self.unfollow.GetValue() == True: return "unfollow"
elif self.mute.GetValue() == True: return "mute"
elif self.unmute.GetValue() == True: return "unmute"
elif self.reportSpam.GetValue() == True: return "report"
elif self.block.GetValue() == True: return "block"
elif self.unblock.GetValue() == True: return "unblock"
elif self.ignore_client.GetValue() == True: return "ignore_client"
def setup_default(self, default):
if default == "follow":
self.follow.SetValue(True)
elif default == "unfollow":
self.unfollow.SetValue(True)
elif default == "mute":
self.mute.SetValue(True)
elif default == "unmute":
self.unmute.SetValue(True)
elif default == "report":
self.reportSpam.SetValue(True)
elif default == "block":
self.block.SetValue(True)
elif default == "unblock":
self.unblock.SetValue(True)
elif default == "ignore_client":
self.ignore_client.SetValue(True)
def get_response(self):
return self.ShowModal()
def get_user(self):
return self.cb.GetValue()
def get_position(self):
return self.cb.GetPosition()
def popup_menu(self, menu):
self.PopupMenu(menu, self.cb.GetPosition())

View File

@@ -1,66 +0,0 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import wx
class selectUserDialog(wx.Dialog):
def __init__(self, users=[], default="tweets", *args, **kwargs):
super(selectUserDialog, self).__init__(parent=None, *args, **kwargs)
panel = wx.Panel(self)
userSizer = wx.BoxSizer()
self.SetTitle(_(u"Timeline for %s") % (users[0]))
userLabel = wx.StaticText(panel, -1, _(u"User"))
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0])
self.cb.SetFocus()
self.autocompletion = wx.Button(panel, -1, _(u"&Autocomplete users"))
userSizer.Add(userLabel, 0, wx.ALL, 5)
userSizer.Add(self.cb, 0, wx.ALL, 5)
userSizer.Add(self.autocompletion, 0, wx.ALL, 5)
actionSizer = wx.BoxSizer(wx.VERTICAL)
label2 = wx.StaticText(panel, -1, _(u"Buffer type"))
self.tweets = wx.RadioButton(panel, -1, _(u"&Tweets"), style=wx.RB_GROUP)
self.favourites = wx.RadioButton(panel, -1, _(u"&Likes"))
self.followers = wx.RadioButton(panel, -1, _(u"&Followers"))
self.friends = wx.RadioButton(panel, -1, _(u"F&riends"))
self.setup_default(default)
hSizer = wx.BoxSizer(wx.HORIZONTAL)
hSizer.Add(label2, 0, wx.ALL, 5)
actionSizer.Add(self.tweets, 0, wx.ALL, 5)
actionSizer.Add(self.favourites, 0, wx.ALL, 5)
actionSizer.Add(self.followers, 0, wx.ALL, 5)
actionSizer.Add(self.friends, 0, wx.ALL, 5)
hSizer.Add(actionSizer, 0, wx.ALL, 5)
sizer = wx.BoxSizer(wx.VERTICAL)
ok = wx.Button(panel, wx.ID_OK, _(u"&OK"))
ok.SetDefault()
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"&Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok)
btnsizer.Add(cancel)
sizer.Add(userSizer)
sizer.Add(hSizer, 0, wx.ALL, 5)
sizer.Add(btnsizer)
panel.SetSizer(sizer)
def get_action(self):
if self.tweets.GetValue() == True: return "tweets"
elif self.favourites.GetValue() == True: return "favourites"
elif self.followers.GetValue() == True: return "followers"
elif self.friends.GetValue() == True: return "friends"
def setup_default(self, default):
if default == "tweets":
self.tweets.SetValue(True)
elif default == "favourites":
self.favourites.SetValue(True)
def get_response(self):
return self.ShowModal()
def get_user(self):
return self.cb.GetValue()
def get_position(self):
return self.cb.GetPosition()
def popup_menu(self, menu):
self.PopupMenu(menu, self.cb.GetPosition())

View File

@@ -1,49 +0,0 @@
# -*- coding: utf-8 -*-
############################################################
# Copyright (c) 2013, 2014 Manuel Eduardo Cortéz Vallejo <manuel@manuelcortez.net>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
############################################################
from __future__ import absolute_import
from __future__ import unicode_literals
import wx
from . import baseDialog
class selectUserDialog(baseDialog.BaseWXDialog):
def __init__(self, title, users):
super(selectUserDialog, self).__init__(parent=None, id=wx.ID_ANY, title=title)
panel = wx.Panel(self)
userSizer = wx.BoxSizer()
self.cb = wx.ComboBox(panel, -1, choices=users, value=users[0], size=wx.DefaultSize)
self.cb.SetFocus()
self.autocompletion = wx.Button(panel, -1, _(u"&Autocomplete users"))
userSizer.Add(wx.StaticText(panel, -1, _(u"User")), 0, wx.ALL, 5)
userSizer.Add(self.cb, 0, wx.ALL, 5)
userSizer.Add(self.autocompletion, 0, wx.ALL, 5)
sizer = wx.BoxSizer(wx.VERTICAL)
ok = wx.Button(panel, wx.ID_OK, _(u"OK"))
ok.SetDefault()
# ok.Bind(wx.EVT_BUTTON, self.onok)
cancel = wx.Button(panel, wx.ID_CANCEL, _(u"Close"))
btnsizer = wx.BoxSizer()
btnsizer.Add(ok, 0, wx.ALL, 5)
btnsizer.Add(cancel, 0, wx.ALL, 5)
sizer.Add(userSizer, 0, wx.ALL, 5)
sizer.Add(btnsizer, 0, wx.ALL, 5)
panel.SetSizer(sizer)
self.SetClientSize(sizer.CalcMin())
def get_user(self):
return self.cb.GetValue()