mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2024-11-23 03:38:08 -06:00
Show more information about tweets on the ViewTweets dialog
This commit is contained in:
parent
3ec8ac31a5
commit
7f673fb9de
@ -30,6 +30,7 @@ class dmPanel(basePanel):
|
||||
super(dmPanel, self).__init__(parent, window, name_buffer, function, argumento=argumento, sound=sound)
|
||||
self.retweetBtn.Disable()
|
||||
self.responseBtn.Disable()
|
||||
self.type = "direct_message"
|
||||
|
||||
def destroy_status(self, ev):
|
||||
index = self.list.get_selected()
|
||||
|
@ -140,3 +140,9 @@ class peoplePanel(basePanel):
|
||||
def remove_buffer(self):
|
||||
pos = None
|
||||
return pos
|
||||
|
||||
def get_message(self, dialog=False):
|
||||
if dialog == False: return " ".join(self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db))
|
||||
else:
|
||||
list = self.compose_function(self.db.settings[self.name_buffer][self.list.get_selected()], self.db)
|
||||
return " ".join(list)
|
||||
|
@ -40,7 +40,7 @@ class searchUsersPanel(peoplePanel):
|
||||
self.create_list()
|
||||
self.args = args
|
||||
self.kwargs = kwargs
|
||||
self.type = "timeline"
|
||||
self.type = "user_search"
|
||||
|
||||
def start_streams(self):
|
||||
num = twitter.starting.search_users(self.db, self.twitter, self.name_buffer, **self.kwargs)
|
||||
|
@ -342,10 +342,10 @@ class reply(tweet):
|
||||
class viewTweet(wx.Dialog):
|
||||
def __init__(self, tweet):
|
||||
super(viewTweet, self).__init__(None, size=(850,850))
|
||||
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet)))
|
||||
self.SetTitle(_(u"Tweet - %i characters ") % (len(tweet["text"])))
|
||||
panel = wx.Panel(self)
|
||||
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, tweet["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)
|
||||
@ -356,6 +356,20 @@ class viewTweet(wx.Dialog):
|
||||
textBox.Add(self.text, 1, wx.EXPAND, 5)
|
||||
mainBox = wx.BoxSizer(wx.VERTICAL)
|
||||
mainBox.Add(textBox, 0, wx.ALL, 5)
|
||||
rtCountLabel = wx.StaticText(panel, -1, _(u"Retweets: "))
|
||||
rtCount = wx.TextCtrl(panel, -1, str(tweet["retweet_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, str(tweet["favorite_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)
|
||||
if platform.system() != "Darwin":
|
||||
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
||||
spellcheck.Bind(wx.EVT_BUTTON, self.onCheck)
|
||||
@ -427,3 +441,87 @@ class viewTweet(wx.Dialog):
|
||||
urlList.unshorten(urls, self).ShowModal()
|
||||
self.text.SetFocus()
|
||||
|
||||
class viewNonTweet(wx.Dialog):
|
||||
def __init__(self, tweet):
|
||||
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=tweet, 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)
|
||||
spellcheck = wx.Button(panel, -1, _("Spelling correction"), size=wx.DefaultSize)
|
||||
spellcheck.Bind(wx.EVT_BUTTON, self.onCheck)
|
||||
self.unshortenButton = wx.Button(panel, -1, _(u"Expand URL"), size=wx.DefaultSize)
|
||||
self.unshortenButton.Bind(wx.EVT_BUTTON, self.onUnshorten)
|
||||
self.unshortenButton.Disable()
|
||||
translateButton = wx.Button(panel, -1, _(u"Translate message"), size=wx.DefaultSize)
|
||||
translateButton.Bind(wx.EVT_BUTTON, self.onTranslate)
|
||||
cancelButton = wx.Button(panel, wx.ID_CANCEL, _(u"Close"), size=wx.DefaultSize)
|
||||
cancelButton.SetDefault()
|
||||
buttonsBox = wx.BoxSizer(wx.HORIZONTAL)
|
||||
buttonsBox.Add(spellcheck, 0, wx.ALL, 5)
|
||||
buttonsBox.Add(self.unshortenButton, 0, wx.ALL, 5)
|
||||
buttonsBox.Add(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())
|
||||
self.check_urls()
|
||||
|
||||
def check_urls(self):
|
||||
if len(twitter.utils.find_urls_in_text(self.text.GetValue())) > 0:
|
||||
self.unshortenButton.Enable()
|
||||
|
||||
def onCheck(self, ev):
|
||||
text = self.text.GetValue()
|
||||
dlg = spellCheckerGUI.spellCheckerDialog(text, "")
|
||||
if dlg.ShowModal() == wx.ID_OK:
|
||||
self.text.ChangeValue(dlg.checker.get_text())
|
||||
dlg.Destroy()
|
||||
|
||||
def onTranslate(self, ev):
|
||||
dlg = translator.gui.translateDialog()
|
||||
selection = dlg.ShowModal()
|
||||
if selection != wx.ID_CANCEL:
|
||||
text_to_translate = self.text.GetValue().encode("utf-8")
|
||||
source = [x[0] for x in translator.available_languages()][dlg.source_lang.GetSelection()]
|
||||
dest = [x[0] for x in translator.available_languages()][dlg.dest_lang.GetSelection()]
|
||||
t = translator.translator.Translator()
|
||||
t.from_lang = source
|
||||
t.to_lang = dest
|
||||
msg = t.translate(text_to_translate)
|
||||
self.text.ChangeValue(msg)
|
||||
output.speak(_(u"Translated"))
|
||||
self.text.SetFocus()
|
||||
else:
|
||||
return
|
||||
dlg.Destroy()
|
||||
|
||||
def onSelect(self, ev):
|
||||
self.text.SelectAll()
|
||||
|
||||
def onUnshorten(self, ev):
|
||||
urls = twitter.utils.find_urls_in_text(self.text.GetValue())
|
||||
if len(urls) == 0:
|
||||
output.speak(_(u"There's no URL to be expanded"))
|
||||
elif len(urls) == 1:
|
||||
self.text.SetValue(self.text.GetValue().replace(urls[0], url_shortener.unshorten(urls[0])))
|
||||
output.speak(_(u"URL expanded"))
|
||||
elif len(urls) > 1:
|
||||
urlList.unshorten(urls, self).ShowModal()
|
||||
self.text.SetFocus()
|
||||
|
@ -662,8 +662,18 @@ class mainFrame(wx.Frame):
|
||||
self.nb.GetCurrentPage().onRetweet(ev)
|
||||
|
||||
def view(self, ev=None):
|
||||
tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
||||
dialogs.message.viewTweet(tweet).ShowModal()
|
||||
tp = self.nb.GetCurrentPage().type
|
||||
if tp == "buffer" or tp == "timeline" or tp == "favourites_timeline" or tp == "list" or tp == "search":
|
||||
try:
|
||||
id = self.db.settings[self.nb.GetCurrentPage().name_buffer][self.nb.GetCurrentPage().list.get_selected()]["id"]
|
||||
tweet = self.twitter.twitter.show_status(id=id)
|
||||
dialogs.message.viewTweet(tweet).ShowModal()
|
||||
except TwythonError as e:
|
||||
non_tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
||||
dialogs.message.viewNonTweet(non_tweet).ShowModal()
|
||||
else:
|
||||
non_tweet = self.nb.GetCurrentPage().get_message(dialog=True)
|
||||
dialogs.message.viewNonTweet(non_tweet).ShowModal()
|
||||
|
||||
def fav(self, ev=None):
|
||||
if self.nb.GetCurrentPage().name_buffer != "direct_messages" and self.nb.GetCurrentPage().name_buffer != "followers" and self.nb.GetCurrentPage().name_buffer != "friends":
|
||||
|
49
src/main.py
49
src/main.py
@ -27,11 +27,7 @@ import paths
|
||||
import config
|
||||
import commandline
|
||||
import platform
|
||||
if platform.system() == "Windows":
|
||||
from logger import logger as logging
|
||||
if platform.system() == "Darwin":
|
||||
import osx_prepare
|
||||
osx_prepare.setup()
|
||||
from logger import logger as logging
|
||||
from sessionmanager import manager
|
||||
from sessionmanager import gui as smGUI
|
||||
manager.setup()
|
||||
@ -41,35 +37,18 @@ if hasattr(sys, 'frozen'):
|
||||
sys.stderr = open(paths.logs_path("stderr.log"), 'w')
|
||||
sys.stdout = open(paths.logs_path("stdout.log"), 'w')
|
||||
|
||||
class app(wx.App):
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(app, self).__init__(*args, **kwargs)
|
||||
if platform.system() != "Darwin":
|
||||
self.start()
|
||||
else:
|
||||
self.mac()
|
||||
|
||||
def mac(self):
|
||||
self.hold_frame = wx.Frame(title="None", parent=None)
|
||||
self.hold_frame.Show()
|
||||
wx.CallLater(10, self.start)
|
||||
|
||||
def start(self):
|
||||
ssmg = smGUI.sessionManagerWindow()
|
||||
if ssmg.ShowModal() == wx.ID_OK:
|
||||
frame = gui.main.mainFrame()
|
||||
frame.Show()
|
||||
frame.showing = True
|
||||
if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows":
|
||||
frame.show_hide()
|
||||
frame.Hide()
|
||||
self.SetTopWindow(frame)
|
||||
if hasattr(self, "frame"): self.hold_frame.Hide()
|
||||
# If the user press on cancel.
|
||||
else:
|
||||
self.Exit()
|
||||
|
||||
ap = app()
|
||||
app = wx.App()
|
||||
ssmg = smGUI.sessionManagerWindow()
|
||||
if ssmg.ShowModal() == wx.ID_OK:
|
||||
frame = gui.main.mainFrame()
|
||||
frame.Show()
|
||||
frame.showing = True
|
||||
if config.main != None and config.main["general"]["hide_gui"] == True and platform.system() == "Windows":
|
||||
frame.show_hide()
|
||||
frame.Hide()
|
||||
app.SetTopWindow(frame)
|
||||
else:
|
||||
app.Exit()
|
||||
### I should uncomment this
|
||||
#if platform.system() != "Windows":
|
||||
# local = wx.Locale(wx.LANGUAGE_DEFAULT)
|
||||
@ -77,5 +56,5 @@ ap = app()
|
||||
# local.AddCatalog("twblue")
|
||||
#ap = app(redirect=True, useBestVisual=True, filename=paths.logs_path('tracebacks.log'))
|
||||
#wx.CallLater(10, start)
|
||||
ap.MainLoop()
|
||||
app.MainLoop()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user