mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-22 19:28:09 -06:00
Delete/view tweets and direct messages has been implemented; some buffer fixes.
This commit is contained in:
parent
a599b37e6d
commit
32884d3bf2
@ -10,6 +10,7 @@ import messages
|
|||||||
from twitter import compose, prettydate, utils
|
from twitter import compose, prettydate, utils
|
||||||
from wxUI import buffers, dialogs, commonMessageDialogs
|
from wxUI import buffers, dialogs, commonMessageDialogs
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
|
from twython import TwythonError
|
||||||
|
|
||||||
class bufferController(object):
|
class bufferController(object):
|
||||||
def __init__(self, parent=None, function=None, session=None, *args, **kwargs):
|
def __init__(self, parent=None, function=None, session=None, *args, **kwargs):
|
||||||
@ -28,7 +29,7 @@ class bufferController(object):
|
|||||||
elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
|
elif ev.GetKeyCode() == wx.WXK_F5: event = "volume_down"
|
||||||
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
|
elif ev.GetKeyCode() == wx.WXK_F6: event = "volume_up"
|
||||||
elif ev.GetKeyCode() == wx.WXK_DELETE and ev.ShiftDown(): event = "clear_list"
|
elif ev.GetKeyCode() == wx.WXK_DELETE and ev.ShiftDown(): event = "clear_list"
|
||||||
elif ev.GetKeyCode() == wx.WXK_DELETE: event = "delete_item"
|
elif ev.GetKeyCode() == wx.WXK_DELETE: event = "destroy_status"
|
||||||
else:
|
else:
|
||||||
event = None
|
event = None
|
||||||
ev.Skip()
|
ev.Skip()
|
||||||
@ -76,6 +77,9 @@ class bufferController(object):
|
|||||||
def get_object(self):
|
def get_object(self):
|
||||||
return self.buffer
|
return self.buffer
|
||||||
|
|
||||||
|
def get_message(self):
|
||||||
|
pass
|
||||||
|
|
||||||
def set_list_position(self, reversed=False):
|
def set_list_position(self, reversed=False):
|
||||||
if reversed == False:
|
if reversed == False:
|
||||||
self.buffer.list.select_item(-1)
|
self.buffer.list.select_item(-1)
|
||||||
@ -91,6 +95,9 @@ class bufferController(object):
|
|||||||
def retweet(self):
|
def retweet(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def destroy_status(self):
|
||||||
|
pass
|
||||||
|
|
||||||
class accountPanel(bufferController):
|
class accountPanel(bufferController):
|
||||||
def __init__(self, parent, name, account):
|
def __init__(self, parent, name, account):
|
||||||
super(accountPanel, self).__init__(parent, None, name)
|
super(accountPanel, self).__init__(parent, None, name)
|
||||||
@ -133,6 +140,9 @@ class baseBufferController(bufferController):
|
|||||||
self.buffer.account = account
|
self.buffer.account = account
|
||||||
self.bind_events()
|
self.bind_events()
|
||||||
|
|
||||||
|
def get_message(self):
|
||||||
|
return " ".join(self.compose_function(self.get_right_tweet(), self.session.db, self.session.settings["general"]["relative_times"])[1:-2])
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
val = self.session.call_paged(self.function, *self.args, **self.kwargs)
|
||||||
number_of_items = self.session.order_buffer(self.name, val)
|
number_of_items = self.session.order_buffer(self.name, val)
|
||||||
@ -257,18 +267,22 @@ class baseBufferController(bufferController):
|
|||||||
self.buffer.list.clear()
|
self.buffer.list.clear()
|
||||||
dlg.Destroy()
|
dlg.Destroy()
|
||||||
|
|
||||||
def delete_item(self):
|
def destroy_status(self, *args, **kwargs):
|
||||||
dlg = wx.MessageDialog(None, _(u"Do you really want to delete this message?"), _(u"Delete"), wx.ICON_QUESTION|wx.YES_NO)
|
index = self.buffer.list.get_selected()
|
||||||
if dlg.ShowModal() == widgetUtils.YES:
|
if self.type == "events" or self.type == "people" or self.type == "empty" or self.type == "account": return
|
||||||
index = self.buffer.list.get_selected()
|
answer = commonMessageDialogs.delete_tweet_dialog(None)
|
||||||
try:
|
if answer == widgetUtils.YES:
|
||||||
self.session.twitter.twitter.destroy_status(id=self.session.db[self.name][index]["id"])
|
# try:
|
||||||
self.session.db[self.name].pop(index)
|
if self.name == "direct_messages":
|
||||||
self.buffer.list.remove_item(index)
|
self.session.twitter.twitter.destroy_direct_message(id=self.get_right_tweet()["id"])
|
||||||
if index > 0:
|
else:
|
||||||
self.buffer.list.select_item(index-1)
|
self.session.twitter.twitter.destroy_status(id=self.get_right_tweet()["id"])
|
||||||
except:
|
self.session.db[self.name].pop(index)
|
||||||
sound.player.play("error.ogg")
|
self.buffer.list.remove_item(index)
|
||||||
|
if index > 0:
|
||||||
|
self.buffer.list.select_item(index-1)
|
||||||
|
# except TwythonError:
|
||||||
|
# sound.player.play("error.ogg")
|
||||||
|
|
||||||
class eventsBufferController(bufferController):
|
class eventsBufferController(bufferController):
|
||||||
def __init__(self, parent, name, session, account, *args, **kwargs):
|
def __init__(self, parent, name, session, account, *args, **kwargs):
|
||||||
@ -280,6 +294,15 @@ class eventsBufferController(bufferController):
|
|||||||
self.buffer.account = self.account
|
self.buffer.account = self.account
|
||||||
self.compose_function = compose.compose_event
|
self.compose_function = compose.compose_event
|
||||||
self.session = session
|
self.session = session
|
||||||
|
self.type = self.buffer.type
|
||||||
|
|
||||||
|
def get_message(self):
|
||||||
|
if self.list.get_count() == 0: return _(u"Empty")
|
||||||
|
# fix this:
|
||||||
|
if platform.system() == "Windows":
|
||||||
|
return "%s. %s" % (self.buffer.list.list.GetItemText(self.buffer.list.get_selected()), self.buffer.list.list.GetItemText(self.buffer.list.get_selected(), 1))
|
||||||
|
else:
|
||||||
|
return self.buffer.list.list.GetStringSelection()
|
||||||
|
|
||||||
def add_new_item(self, item):
|
def add_new_item(self, item):
|
||||||
tweet = self.compose_function(item, self.session.db["user_name"])
|
tweet = self.compose_function(item, self.session.db["user_name"])
|
||||||
@ -297,6 +320,9 @@ class peopleBufferController(baseBufferController):
|
|||||||
def onFocus(self, ev):
|
def onFocus(self, ev):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
def get_message(self):
|
||||||
|
return " ".join(self.compose_function(self.get_tweet(), self.session.db, self.session.settings["general"]["relative_times"]))
|
||||||
|
|
||||||
def delete_item(self): pass
|
def delete_item(self): pass
|
||||||
|
|
||||||
def start_stream(self):
|
def start_stream(self):
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
from wxUI import (view, dialogs)
|
from wxUI import (view, dialogs, commonMessageDialogs)
|
||||||
import buffersController
|
import buffersController
|
||||||
import messages
|
import messages
|
||||||
from sessionmanager import session
|
from sessionmanager import session
|
||||||
from pubsub import pub
|
from pubsub import pub
|
||||||
import sound
|
import sound
|
||||||
import output
|
import output
|
||||||
|
from twython import TwythonError
|
||||||
from mysc.thread_utils import call_threaded
|
from mysc.thread_utils import call_threaded
|
||||||
from mysc.repeating_timer import RepeatingTimer
|
from mysc.repeating_timer import RepeatingTimer
|
||||||
import config
|
import config
|
||||||
@ -29,6 +30,12 @@ class Controller(object):
|
|||||||
for i in self.buffers:
|
for i in self.buffers:
|
||||||
if i.name == name_ and i.account == user: return i
|
if i.name == name_ and i.account == user: return i
|
||||||
|
|
||||||
|
def get_current_buffer(self):
|
||||||
|
buffer = self.view.get_current_buffer()
|
||||||
|
if hasattr(buffer, "account"):
|
||||||
|
buffer = self.search_buffer(buffer.name, buffer.account)
|
||||||
|
return buffer
|
||||||
|
|
||||||
def get_best_buffer(self):
|
def get_best_buffer(self):
|
||||||
# Gets the parent buffer to know what account is doing an action
|
# Gets the parent buffer to know what account is doing an action
|
||||||
view_buffer = self.view.get_current_buffer()
|
view_buffer = self.view.get_current_buffer()
|
||||||
@ -66,6 +73,8 @@ class Controller(object):
|
|||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_retweet, self.view.retweet)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.post_retweet, self.view.retweet)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_favourites, self.view.fav)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.add_to_favourites, self.view.fav)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_favourites, self.view.unfav)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.remove_from_favourites, self.view.unfav)
|
||||||
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.view_item, self.view.view)
|
||||||
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.delete, self.view.delete)
|
||||||
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.send_dm, self.view.dm)
|
widgetUtils.connect_event(self.view, widgetUtils.MENU, self.send_dm, self.view.dm)
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -206,8 +215,11 @@ class Controller(object):
|
|||||||
def show_details_for_user(self, user):
|
def show_details_for_user(self, user):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def delete(self):
|
def delete(self, *args, **kwargs):
|
||||||
pass
|
buffer = self.view.get_current_buffer()
|
||||||
|
if hasattr(buffer, "account"):
|
||||||
|
buffer = self.search_buffer(buffer.name, buffer.account)
|
||||||
|
buffer.destroy_status()
|
||||||
|
|
||||||
def exit(self, *args, **kwargs):
|
def exit(self, *args, **kwargs):
|
||||||
for item in session.sessions:
|
for item in session.sessions:
|
||||||
@ -233,7 +245,7 @@ class Controller(object):
|
|||||||
call_threaded(buffer.session.api_call, call_name="update_status_with_media", _sound="tweet_send.ogg", status=text, media=tweet.image)
|
call_threaded(buffer.session.api_call, call_name="update_status_with_media", _sound="tweet_send.ogg", status=text, media=tweet.image)
|
||||||
|
|
||||||
def post_reply(self, *args, **kwargs):
|
def post_reply(self, *args, **kwargs):
|
||||||
buffer = self.get_best_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.name == "sent_direct_messages" or buffer.name == "sent-tweets": return
|
if buffer.name == "sent_direct_messages" or buffer.name == "sent-tweets": return
|
||||||
elif buffer.name == "direct_messages":
|
elif buffer.name == "direct_messages":
|
||||||
buffer.direct_message()
|
buffer.direct_message()
|
||||||
@ -241,20 +253,20 @@ class Controller(object):
|
|||||||
buffer.reply()
|
buffer.reply()
|
||||||
|
|
||||||
def send_dm(self, user):
|
def send_dm(self, user):
|
||||||
buffer = self.get_best_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.name == "sent_direct_messages" or buffer.name == "sent-tweets": return
|
if buffer.name == "sent_direct_messages" or buffer.name == "sent-tweets": return
|
||||||
else:
|
else:
|
||||||
buffer.direct_message()
|
buffer.direct_message()
|
||||||
|
|
||||||
def post_retweet(self, *args, **kwargs):
|
def post_retweet(self, *args, **kwargs):
|
||||||
buffer = self.get_best_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
buffer.retweet()
|
buffer.retweet()
|
||||||
|
|
||||||
def add_to_favourites(self, *args, **kwargs):
|
def add_to_favourites(self, *args, **kwargs):
|
||||||
buffer = self.get_best_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -262,13 +274,28 @@ class Controller(object):
|
|||||||
call_threaded(buffer.session.api_call, call_name="create_favorite", _sound="favourite.ogg", id=id)
|
call_threaded(buffer.session.api_call, call_name="create_favorite", _sound="favourite.ogg", id=id)
|
||||||
|
|
||||||
def remove_from_favourites(self, *args, **kwargs):
|
def remove_from_favourites(self, *args, **kwargs):
|
||||||
buffer = self.get_best_buffer()
|
buffer = self.get_current_buffer()
|
||||||
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
if buffer.type == "dm" or buffer.type == "people" or buffer.type == "events":
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
id = buffer.get_tweet()["id"]
|
id = buffer.get_tweet()["id"]
|
||||||
call_threaded(buffer.session.api_call, call_name="destroy_favorite", id=id)
|
call_threaded(buffer.session.api_call, call_name="destroy_favorite", id=id)
|
||||||
|
|
||||||
|
def view_item(self, *args, **kwargs):
|
||||||
|
buffer = self.get_current_buffer()
|
||||||
|
if buffer.type == "baseBuffer" or buffer.type == "favourites_timeline" or buffer.type == "list" or buffer.type == "search":
|
||||||
|
try:
|
||||||
|
tweet = buffer.get_right_tweet()
|
||||||
|
msg = messages.viewTweet(tweet, )
|
||||||
|
except TwythonError:
|
||||||
|
non_tweet = buffer.get_message()
|
||||||
|
msg = messages.viewTweet(non_tweet, False)
|
||||||
|
elif buffer.type == "account" or buffer.type == "empty":
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
non_tweet = buffer.get_message()
|
||||||
|
msg = messages.viewTweet(non_tweet, False)
|
||||||
|
|
||||||
def open_timeline(self, user, timeline_tipe):
|
def open_timeline(self, user, timeline_tipe):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -128,3 +128,28 @@ class reply(tweet):
|
|||||||
class dm(basicTweet):
|
class dm(basicTweet):
|
||||||
def __init__(self, session, title, caption, text):
|
def __init__(self, session, title, caption, text):
|
||||||
super(dm, self).__init__(session, title, caption, text, messageType="dm")
|
super(dm, self).__init__(session, title, caption, text, messageType="dm")
|
||||||
|
|
||||||
|
class viewTweet(basicTweet):
|
||||||
|
def __init__(self, tweet, is_tweet=True):
|
||||||
|
if is_tweet == True:
|
||||||
|
if tweet.has_key("retweeted_status"):
|
||||||
|
text = "rt @%s: %s" % (tweet["retweeted_status"]["user"]["screen_name"], tweet["retweeted_status"]["text"])
|
||||||
|
else:
|
||||||
|
text = tweet["text"]
|
||||||
|
rt_count = str(tweet["retweet_count"])
|
||||||
|
favs_count = str(tweet["favorite_count"])
|
||||||
|
self.message = message.viewTweet(text, rt_count, favs_count)
|
||||||
|
self.message.set_title(len(text))
|
||||||
|
else:
|
||||||
|
text = tweet
|
||||||
|
self.message = message.viewNonTweet(text)
|
||||||
|
widgetUtils.connect_event(self.message.spellcheck, widgetUtils.BUTTON_PRESSED, self.spellcheck)
|
||||||
|
widgetUtils.connect_event(self.message.translateButton, widgetUtils.BUTTON_PRESSED, self.translate)
|
||||||
|
if self.contain_urls() == True:
|
||||||
|
widgetUtils.connect_event(self.message.unshortenButton, widgetUtils.BUTTON_PRESSED, self.unshorten)
|
||||||
|
self.message.get_response()
|
||||||
|
|
||||||
|
def contain_urls(self):
|
||||||
|
if len(utils.find_urls_in_text(self.message.get_text())) > 0:
|
||||||
|
return True
|
||||||
|
return False
|
@ -3,3 +3,6 @@ import wx
|
|||||||
|
|
||||||
def retweet_question(parent):
|
def retweet_question(parent):
|
||||||
return wx.MessageDialog(parent, _(u"Would you like to add a comment to this tweet?"), _("Retweet"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION).ShowModal()
|
return wx.MessageDialog(parent, _(u"Would you like to add a comment to this tweet?"), _("Retweet"), wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION).ShowModal()
|
||||||
|
|
||||||
|
def delete_tweet_dialog(parent):
|
||||||
|
return wx.MessageDialog(parent, _(u"Do you really want to delete this message? It will be eliminated from Twitter as well."), _(u"Delete"), wx.ICON_QUESTION|wx.YES_NO).ShowModal()
|
||||||
|
@ -155,13 +155,15 @@ class reply(tweet):
|
|||||||
self.mainBox.Layout()
|
self.mainBox.Layout()
|
||||||
self.SetClientSize(self.mainBox.CalcMin())
|
self.SetClientSize(self.mainBox.CalcMin())
|
||||||
|
|
||||||
class viewTweet(wx.Dialog):
|
class viewTweet(widgetUtils.BaseDialog):
|
||||||
def __init__(self, tweet):
|
def set_title(self, lenght):
|
||||||
|
self.SetTitle(_(u"Tweet - %i characters ") % (lenght,))
|
||||||
|
|
||||||
|
def __init__(self, text, rt_count, favs_count):
|
||||||
super(viewTweet, self).__init__(None, size=(850,850))
|
super(viewTweet, self).__init__(None, size=(850,850))
|
||||||
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet)))
|
|
||||||
panel = wx.Panel(self)
|
panel = wx.Panel(self)
|
||||||
label = wx.StaticText(panel, -1, _(u"Tweet"))
|
label = wx.StaticText(panel, -1, _(u"Tweet"))
|
||||||
self.text = wx.TextCtrl(panel, -1, tweet, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
|
self.text = wx.TextCtrl(panel, -1, text, style=wx.TE_READONLY|wx.TE_MULTILINE, size=(250, 180))
|
||||||
dc = wx.WindowDC(self.text)
|
dc = wx.WindowDC(self.text)
|
||||||
dc.SetFont(self.text.GetFont())
|
dc.SetFont(self.text.GetFont())
|
||||||
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
(x, y, z) = dc.GetMultiLineTextExtent("0"*140)
|
||||||
@ -172,15 +174,81 @@ class viewTweet(wx.Dialog):
|
|||||||
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
||||||
mainBox = wx.BoxSizer(wx.VERTICAL)
|
mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||||
mainBox.Add(textBox, 0, wx.ALL, 5)
|
mainBox.Add(textBox, 0, wx.ALL, 5)
|
||||||
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
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"Favourites: "))
|
||||||
|
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)
|
||||||
|
infoBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
infoBox.Add(rtBox, 0, wx.ALL, 5)
|
||||||
|
infoBox.Add(favsBox, 0, wx.ALL, 5)
|
||||||
|
mainBox.Add(infoBox, 0, wx.ALL, 5)
|
||||||
|
self.spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
||||||
self.unshortenButton = wx.Button(panel, -1, _(u"Expand URL"), size=wx.DefaultSize)
|
self.unshortenButton = wx.Button(panel, -1, _(u"Expand URL"), size=wx.DefaultSize)
|
||||||
self.unshortenButton.Disable()
|
self.unshortenButton.Disable()
|
||||||
translateButton = wx.Button(panel, -1, _(u"Translate message"), size=wx.DefaultSize)
|
self.translateButton = wx.Button(panel, -1, _(u"Translate message"), size=wx.DefaultSize)
|
||||||
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
||||||
|
cancelButton.SetDefault()
|
||||||
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
|
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
buttonsBox.Add(spellcheck, 0, wx.ALL, 5)
|
buttonsBox.Add(self.spellcheck, 0, wx.ALL, 5)
|
||||||
buttonsBox.Add(self.unshortenButton, 0, wx.ALL, 5)
|
buttonsBox.Add(self.unshortenButton, 0, wx.ALL, 5)
|
||||||
buttonsBox.Add(translateButton, 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.NewId()
|
||||||
|
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()
|
||||||
|
|
||||||
|
def get_text(self):
|
||||||
|
return self.text.GetValue()
|
||||||
|
|
||||||
|
def text_focus(self):
|
||||||
|
self.text.SetFocus()
|
||||||
|
|
||||||
|
def onSelect(self, ev):
|
||||||
|
self.text.SelectAll()
|
||||||
|
|
||||||
|
class viewNonTweet(widgetUtils.BaseDialog):
|
||||||
|
|
||||||
|
def __init__(self, text):
|
||||||
|
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, z) = 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)
|
||||||
|
self.spellcheck = wx.Button(panel, -1, _("Spelling correction"), 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 message"), size=wx.DefaultSize)
|
||||||
|
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
||||||
|
cancelButton.SetDefault()
|
||||||
|
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
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)
|
buttonsBox.Add(cancelButton, 0, wx.ALL, 5)
|
||||||
mainBox.Add(buttonsBox, 0, wx.ALL, 5)
|
mainBox.Add(buttonsBox, 0, wx.ALL, 5)
|
||||||
selectId = wx.NewId()
|
selectId = wx.NewId()
|
||||||
@ -194,3 +262,12 @@ class viewTweet(wx.Dialog):
|
|||||||
|
|
||||||
def onSelect(self, ev):
|
def onSelect(self, ev):
|
||||||
self.text.SelectAll()
|
self.text.SelectAll()
|
||||||
|
|
||||||
|
def set_text(self, text):
|
||||||
|
self.text.ChangeValue()
|
||||||
|
|
||||||
|
def get_text(self):
|
||||||
|
return self.text.GetValue()
|
||||||
|
|
||||||
|
def text_focus(self):
|
||||||
|
self.text.SetFocus()
|
||||||
|
Loading…
Reference in New Issue
Block a user