2014-11-12 20:41:29 -06:00
# -*- coding: utf-8 -*-
import wx
2014-12-31 00:07:27 -06:00
import widgetUtils
2014-11-12 20:41:29 -06:00
2014-12-31 00:07:27 -06:00
class textLimited ( widgetUtils . BaseDialog ) :
2014-11-12 20:41:29 -06:00
def __init__ ( self , * args , * * kwargs ) :
super ( textLimited , self ) . __init__ ( parent = None , * args , * * kwargs )
2016-12-09 10:15:39 -06:00
2014-11-12 20:41:29 -06:00
def createTextArea ( self , message = " " , text = " " ) :
2016-04-11 08:21:29 -05:00
if not hasattr ( self , " panel " ) :
self . panel = wx . Panel ( self )
2014-11-12 20:41:29 -06:00
self . label = wx . StaticText ( self . panel , - 1 , message )
self . SetTitle ( str ( len ( text ) ) )
2015-05-15 21:39:01 -04:00
self . text = wx . TextCtrl ( self . panel , - 1 , text , size = ( 439 , - 1 ) , style = wx . TE_MULTILINE | wx . TE_PROCESS_ENTER )
2015-03-20 17:04:39 -06:00
# font = self.text.GetFont()
# dc = wx.WindowDC(self.text)
# dc.SetFont(font)
# x, y = dc.GetTextExtent("00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")
# self.text.SetSize((x, y))
2015-07-13 17:39:02 -05:00
self . Bind ( wx . EVT_CHAR_HOOK , self . handle_keys , self . text )
2014-11-12 20:41:29 -06:00
self . text . SetFocus ( )
self . textBox = wx . BoxSizer ( wx . HORIZONTAL )
self . textBox . Add ( self . label , 0 , wx . ALL , 5 )
self . textBox . Add ( self . text , 0 , wx . ALL , 5 )
2014-12-31 00:07:27 -06:00
def text_focus ( self ) :
self . text . SetFocus ( )
2014-11-12 20:41:29 -06:00
def get_text ( self ) :
return self . text . GetValue ( )
2014-11-12 22:37:52 -06:00
def set_text ( self , text ) :
return self . text . ChangeValue ( text )
2014-11-15 19:40:19 -06:00
def set_title ( self , new_title ) :
return self . SetTitle ( new_title )
def enable_button ( self , buttonName ) :
2017-05-06 23:33:56 +04:00
if hasattr ( self , buttonName ) :
2014-11-15 19:40:19 -06:00
return getattr ( self , buttonName ) . Enable ( )
def disable_button ( self , buttonName ) :
2017-05-06 23:33:56 +04:00
if hasattr ( self , buttonName ) :
2014-11-15 19:40:19 -06:00
return getattr ( self , buttonName ) . Disable ( )
2014-11-12 20:41:29 -06:00
def onSelect ( self , ev ) :
self . text . SelectAll ( )
2015-07-13 17:39:02 -05:00
def handle_keys ( self , event ) :
shift = event . ShiftDown ( )
if event . GetKeyCode ( ) == wx . WXK_RETURN and shift == False and hasattr ( self , ' okButton ' ) :
wx . PostEvent ( self . okButton . GetEventHandler ( ) , wx . PyCommandEvent ( wx . EVT_BUTTON . typeId , wx . ID_OK ) )
2015-05-16 19:25:02 -04:00
else :
2015-07-13 17:39:02 -05:00
event . Skip ( )
2015-05-16 19:25:02 -04:00
2015-01-02 09:38:44 -06:00
def set_cursor_at_end ( self ) :
self . text . SetInsertionPoint ( len ( self . text . GetValue ( ) ) )
def set_cursor_at_position ( self , position ) :
self . text . SetInsertionPoint ( position )
2015-01-27 17:09:28 -06:00
def get_position ( self ) :
return self . text . GetInsertionPoint ( )
def popup_menu ( self , menu ) :
self . PopupMenu ( menu , self . text . GetPosition ( ) )
2015-01-02 09:38:44 -06:00
2014-11-12 20:41:29 -06:00
class tweet ( textLimited ) :
2015-01-02 09:38:44 -06:00
def createControls ( self , title , message , text ) :
2014-11-12 20:41:29 -06:00
self . mainBox = wx . BoxSizer ( wx . VERTICAL )
self . createTextArea ( message , text )
self . mainBox . Add ( self . textBox , 0 , wx . ALL , 5 )
2016-03-20 10:26:05 -04:00
self . long_tweet = wx . CheckBox ( self . panel , - 1 , _ ( u " &Long tweet " ) )
self . upload_image = wx . Button ( self . panel , - 1 , _ ( u " &Upload image... " ) , size = wx . DefaultSize )
self . spellcheck = wx . Button ( self . panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . attach = wx . Button ( self . panel , - 1 , _ ( u " &Attach audio... " ) , size = wx . DefaultSize )
self . shortenButton = wx . Button ( self . panel , - 1 , _ ( u " Sh&orten URL " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( self . panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . shortenButton . Disable ( )
self . unshortenButton . Disable ( )
2016-03-20 10:26:05 -04:00
self . translateButton = wx . Button ( self . panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
2016-07-19 09:30:43 -05:00
self . autocompletionButton = wx . Button ( self . panel , - 1 , _ ( u " Auto&complete users " ) )
self . okButton = wx . Button ( self . panel , wx . ID_OK , _ ( u " Sen&d " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . okButton . SetDefault ( )
2016-07-19 09:30:43 -05:00
cancelButton = wx . Button ( self . panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . buttonsBox1 = wx . BoxSizer ( wx . HORIZONTAL )
2015-03-20 17:04:39 -06:00
self . buttonsBox1 . Add ( self . upload_image , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . spellcheck , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . attach , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox1 , 0 , wx . ALL , 10 )
2014-11-12 20:41:29 -06:00
self . buttonsBox2 = wx . BoxSizer ( wx . HORIZONTAL )
2015-03-20 17:04:39 -06:00
self . buttonsBox2 . Add ( self . shortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . unshortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . translateButton , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox2 , 0 , wx . ALL , 10 )
2014-11-12 20:41:29 -06:00
self . ok_cancelSizer = wx . BoxSizer ( wx . HORIZONTAL )
2015-03-20 17:04:39 -06:00
self . ok_cancelSizer . Add ( self . autocompletionButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( self . okButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( cancelButton , 0 , wx . ALL , 10 )
2014-11-12 20:41:29 -06:00
self . mainBox . Add ( self . ok_cancelSizer )
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 )
self . panel . SetSizer ( self . mainBox )
2016-12-09 10:15:39 -06:00
def __init__ ( self , title , message , text , * args , * * kwargs ) :
2014-11-12 20:41:29 -06:00
super ( tweet , self ) . __init__ ( )
2015-05-15 23:48:12 -04:00
self . shift = False
2014-11-12 20:41:29 -06:00
self . createControls ( message , title , text )
self . SetClientSize ( self . mainBox . CalcMin ( ) )
2014-12-31 00:07:27 -06:00
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
return open ( openFileDialog . GetPath ( ) , " rb " )
2015-04-08 13:34:50 -05:00
2015-05-16 19:25:02 -04:00
2015-04-08 13:34:50 -05:00
class retweet ( tweet ) :
def createControls ( self , title , message , text ) :
self . mainBox = wx . BoxSizer ( wx . VERTICAL )
self . createTextArea ( message , " " )
label = wx . StaticText ( self . panel , - 1 , _ ( u " Retweet " ) )
self . text2 = wx . TextCtrl ( self . panel , - 1 , text , size = ( 439 , - 1 ) , style = wx . TE_MULTILINE | wx . TE_READONLY )
self . retweetBox = wx . BoxSizer ( wx . HORIZONTAL )
self . retweetBox . Add ( label , 0 , wx . ALL , 5 )
self . retweetBox . Add ( self . text2 , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . textBox , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . retweetBox , 0 , wx . ALL , 5 )
2016-07-19 09:30:43 -05:00
self . upload_image = wx . Button ( self . panel , - 1 , _ ( u " &Upload image... " ) , size = wx . DefaultSize )
self . spellcheck = wx . Button ( self . panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . attach = wx . Button ( self . panel , - 1 , _ ( u " &Attach audio... " ) , size = wx . DefaultSize )
self . shortenButton = wx . Button ( self . panel , - 1 , _ ( u " Sh&orten URL " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( self . panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
2015-04-08 13:34:50 -05:00
self . shortenButton . Disable ( )
self . unshortenButton . Disable ( )
2016-07-19 09:30:43 -05:00
self . translateButton = wx . Button ( self . panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
self . autocompletionButton = wx . Button ( self . panel , - 1 , _ ( u " Auto&complete users " ) )
self . okButton = wx . Button ( self . panel , wx . ID_OK , _ ( u " Sen&d " ) , size = wx . DefaultSize )
2015-04-08 13:34:50 -05:00
self . okButton . SetDefault ( )
2016-07-19 09:30:43 -05:00
cancelButton = wx . Button ( self . panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
2015-04-08 13:34:50 -05:00
self . buttonsBox1 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox1 . Add ( self . upload_image , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . spellcheck , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . attach , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox1 , 0 , wx . ALL , 10 )
self . buttonsBox2 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox2 . Add ( self . shortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . unshortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . translateButton , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox2 , 0 , wx . ALL , 10 )
self . ok_cancelSizer = wx . BoxSizer ( wx . HORIZONTAL )
self . ok_cancelSizer . Add ( self . autocompletionButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( self . okButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( cancelButton , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . ok_cancelSizer )
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 )
self . panel . SetSizer ( self . mainBox )
2016-12-09 10:15:39 -06:00
def __init__ ( self , title , message , text , * args , * * kwargs ) :
2015-04-08 13:34:50 -05:00
super ( tweet , self ) . __init__ ( )
self . createControls ( message , title , text )
# self.onTimer(wx.EVT_CHAR_HOOK)
self . SetClientSize ( self . mainBox . CalcMin ( ) )
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
return open ( openFileDialog . GetPath ( ) , " rb " )
2014-11-12 20:41:29 -06:00
class dm ( textLimited ) :
2015-01-02 09:38:44 -06:00
def createControls ( self , title , message , users ) :
2014-11-12 20:41:29 -06:00
self . panel = wx . Panel ( self )
self . mainBox = wx . BoxSizer ( wx . VERTICAL )
2016-07-19 09:30:43 -05:00
label = wx . StaticText ( self . panel , - 1 , _ ( u " &Recipient " ) )
2014-11-12 20:41:29 -06:00
self . cb = wx . ComboBox ( self . panel , - 1 , choices = users , value = users [ 0 ] , size = wx . DefaultSize )
2016-07-19 09:30:43 -05:00
self . autocompletionButton = wx . Button ( self . panel , - 1 , _ ( u " Auto&complete users " ) )
2014-11-12 20:41:29 -06:00
self . createTextArea ( message , text = " " )
2015-03-12 12:24:34 -06:00
userBox = wx . BoxSizer ( wx . HORIZONTAL )
userBox . Add ( label , 0 , wx . ALL , 5 )
userBox . Add ( self . cb , 0 , wx . ALL , 5 )
userBox . Add ( self . autocompletionButton , 0 , wx . ALL , 5 )
self . mainBox . Add ( userBox , 0 , wx . ALL , 5 )
2014-11-12 20:41:29 -06:00
self . mainBox . Add ( self . textBox , 0 , wx . ALL , 5 )
2016-07-19 09:30:43 -05:00
self . spellcheck = wx . Button ( self . panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . attach = wx . Button ( self . panel , - 1 , _ ( u " &Attach audio... " ) , size = wx . DefaultSize )
self . shortenButton = wx . Button ( self . panel , - 1 , _ ( u " Sh&orten URL " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( self . panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . shortenButton . Disable ( )
self . unshortenButton . Disable ( )
2016-07-19 09:30:43 -05:00
self . translateButton = wx . Button ( self . panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
self . okButton = wx . Button ( self . panel , wx . ID_OK , _ ( u " Sen&d " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . okButton . SetDefault ( )
2016-07-19 09:30:43 -05:00
cancelButton = wx . Button ( self . panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . buttonsBox = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox . Add ( self . spellcheck , 0 , wx . ALL , 5 )
self . buttonsBox . Add ( self . attach , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . buttonsBox , 0 , wx . ALL , 5 )
self . buttonsBox1 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox1 . Add ( self . shortenButton , 0 , wx . ALL , 5 )
self . buttonsBox1 . Add ( self . unshortenButton , 0 , wx . ALL , 5 )
self . buttonsBox1 . Add ( self . translateButton , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . buttonsBox1 , 0 , wx . ALL , 5 )
self . buttonsBox3 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox3 . Add ( self . okButton , 0 , wx . ALL , 5 )
self . buttonsBox3 . Add ( cancelButton , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . buttonsBox3 , 0 , wx . ALL , 5 )
self . panel . SetSizer ( self . mainBox )
2016-04-11 08:21:29 -05:00
self . SetClientSize ( self . mainBox . CalcMin ( ) )
2015-08-24 09:54:15 -05:00
2016-12-09 10:15:39 -06:00
def __init__ ( self , title , message , users , * args , * * kwargs ) :
2014-11-12 20:41:29 -06:00
super ( dm , self ) . __init__ ( )
self . createControls ( message , title , users )
# self.onTimer(wx.EVT_CHAR_HOOK)
2016-04-11 08:21:29 -05:00
# self.SetClientSize(self.mainBox.CalcMin())
2015-01-02 09:38:44 -06:00
def get_user ( self ) :
return self . cb . GetValue ( )
2015-03-12 12:24:34 -06:00
def set_user ( self , user ) :
return self . cb . SetValue ( user )
2016-12-09 10:15:39 -06:00
class reply ( textLimited ) :
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
return open ( openFileDialog . GetPath ( ) , " rb " )
def createControls ( self , title , message , text ) :
self . mainBox = wx . BoxSizer ( wx . VERTICAL )
self . createTextArea ( message , text )
self . mainBox . Add ( self . textBox , 0 , wx . ALL , 5 )
self . usersbox = wx . BoxSizer ( wx . VERTICAL )
self . mentionAll = wx . CheckBox ( self . panel , - 1 , _ ( u " &Mention to all " ) , size = wx . DefaultSize )
2018-02-06 16:47:47 -06:00
self . mentionAll . Disable ( )
2016-12-09 10:15:39 -06:00
self . usersbox . Add ( self . mentionAll , 0 , wx . ALL , 5 )
self . checkboxes = [ ]
for i in self . users :
user_checkbox = wx . CheckBox ( self . panel , - 1 , " @ " + i , size = wx . DefaultSize )
self . checkboxes . append ( user_checkbox )
self . usersbox . Add ( self . checkboxes [ - 1 ] , 0 , wx . ALL , 5 )
self . mainBox . Add ( self . usersbox , 0 , wx . ALL , 10 )
self . long_tweet = wx . CheckBox ( self . panel , - 1 , _ ( u " &Long tweet " ) )
self . upload_image = wx . Button ( self . panel , - 1 , _ ( u " &Upload image... " ) , size = wx . DefaultSize )
self . spellcheck = wx . Button ( self . panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . attach = wx . Button ( self . panel , - 1 , _ ( u " &Attach audio... " ) , size = wx . DefaultSize )
self . shortenButton = wx . Button ( self . panel , - 1 , _ ( u " Sh&orten URL " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( self . panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
self . shortenButton . Disable ( )
self . unshortenButton . Disable ( )
self . translateButton = wx . Button ( self . panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
self . autocompletionButton = wx . Button ( self . panel , - 1 , _ ( u " Auto&complete users " ) )
self . okButton = wx . Button ( self . panel , wx . ID_OK , _ ( u " Sen&d " ) , size = wx . DefaultSize )
self . okButton . SetDefault ( )
cancelButton = wx . Button ( self . panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
self . buttonsBox1 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox1 . Add ( self . upload_image , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . spellcheck , 0 , wx . ALL , 10 )
self . buttonsBox1 . Add ( self . attach , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox1 , 0 , wx . ALL , 10 )
self . buttonsBox2 = wx . BoxSizer ( wx . HORIZONTAL )
self . buttonsBox2 . Add ( self . shortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . unshortenButton , 0 , wx . ALL , 10 )
self . buttonsBox2 . Add ( self . translateButton , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . buttonsBox2 , 0 , wx . ALL , 10 )
self . ok_cancelSizer = wx . BoxSizer ( wx . HORIZONTAL )
self . ok_cancelSizer . Add ( self . autocompletionButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( self . okButton , 0 , wx . ALL , 10 )
self . ok_cancelSizer . Add ( cancelButton , 0 , wx . ALL , 10 )
self . mainBox . Add ( self . ok_cancelSizer , 0 , wx . ALL , 10 )
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 )
self . panel . SetSizer ( self . mainBox )
def __init__ ( self , title , message , text , users = [ ] , * args , * * kwargs ) :
self . users = users
super ( reply , self ) . __init__ ( )
self . shift = False
self . createControls ( message , title , text )
2014-11-12 20:41:29 -06:00
self . SetClientSize ( self . mainBox . CalcMin ( ) )
2015-01-05 05:33:09 -06:00
class viewTweet ( widgetUtils . BaseDialog ) :
def set_title ( self , lenght ) :
self . SetTitle ( _ ( u " Tweet - %i characters " ) % ( lenght , ) )
2016-12-09 10:15:39 -06:00
def __init__ ( self , text , rt_count , favs_count , source , * args , * * kwargs ) :
2014-11-12 20:41:29 -06:00
super ( viewTweet , self ) . __init__ ( None , size = ( 850 , 850 ) )
panel = wx . Panel ( self )
label = wx . StaticText ( panel , - 1 , _ ( u " Tweet " ) )
2015-01-05 05:33:09 -06:00
self . text = wx . TextCtrl ( panel , - 1 , text , style = wx . TE_READONLY | wx . TE_MULTILINE , size = ( 250 , 180 ) )
2014-11-12 20:41:29 -06:00
dc = wx . WindowDC ( self . text )
dc . SetFont ( self . text . GetFont ( ) )
2018-03-14 14:18:11 -06:00
( x , y ) = dc . GetMultiLineTextExtent ( " 0 " * 140 )
2014-11-12 20:41:29 -06:00
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 )
2016-03-29 15:12:16 -06:00
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 ( ) )
2018-03-14 14:18:11 -06:00
( x , y ) = dc . GetMultiLineTextExtent ( " 0 " * 450 )
2016-03-29 15:12:16 -06:00
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 )
2015-01-05 05:33:09 -06:00
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 )
2015-11-03 10:07:06 -06:00
favsCountLabel = wx . StaticText ( panel , - 1 , _ ( u " Likes: " ) )
2015-01-05 05:33:09 -06:00
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 )
2016-01-09 00:45:52 -06:00
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 )
2015-01-05 05:33:09 -06:00
infoBox = wx . BoxSizer ( wx . HORIZONTAL )
infoBox . Add ( rtBox , 0 , wx . ALL , 5 )
infoBox . Add ( favsBox , 0 , wx . ALL , 5 )
2016-01-09 00:45:52 -06:00
infoBox . Add ( sourceBox , 0 , wx . ALL , 5 )
2015-01-05 05:33:09 -06:00
mainBox . Add ( infoBox , 0 , wx . ALL , 5 )
2016-07-19 09:30:43 -05:00
self . spellcheck = wx . Button ( panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
2014-11-12 20:41:29 -06:00
self . unshortenButton . Disable ( )
2016-07-19 09:30:43 -05:00
self . translateButton = wx . Button ( panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
cancelButton = wx . Button ( panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
2015-01-05 05:33:09 -06:00
cancelButton . SetDefault ( )
2014-11-12 20:41:29 -06:00
buttonsBox = wx . BoxSizer ( wx . HORIZONTAL )
2015-01-05 05:33:09 -06:00
buttonsBox . Add ( self . spellcheck , 0 , wx . ALL , 5 )
2014-11-12 20:41:29 -06:00
buttonsBox . Add ( self . unshortenButton , 0 , wx . ALL , 5 )
2015-01-05 05:33:09 -06:00
buttonsBox . Add ( self . translateButton , 0 , wx . ALL , 5 )
2014-11-12 20:41:29 -06:00
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 ( ) )
2015-01-05 05:33:09 -06:00
def set_text ( self , text ) :
2015-01-13 12:31:37 -06:00
self . text . ChangeValue ( text )
2015-01-05 05:33:09 -06:00
def get_text ( self ) :
return self . text . GetValue ( )
2016-03-29 15:12:16 -06:00
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 )
2015-01-05 05:33:09 -06:00
def text_focus ( self ) :
self . text . SetFocus ( )
2014-11-12 20:41:29 -06:00
def onSelect ( self , ev ) :
2015-01-05 05:33:09 -06:00
self . text . SelectAll ( )
2015-03-12 11:45:53 -06:00
def enable_button ( self , buttonName ) :
2017-05-06 23:33:56 +04:00
if hasattr ( self , buttonName ) :
2015-03-12 11:45:53 -06:00
return getattr ( self , buttonName ) . Enable ( )
2015-01-05 05:33:09 -06:00
class viewNonTweet ( widgetUtils . BaseDialog ) :
2016-12-09 10:15:39 -06:00
def __init__ ( self , text , * args , * * kwargs ) :
2015-01-05 05:33:09 -06:00
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 ( ) )
2018-03-14 14:18:11 -06:00
( x , y ) = dc . GetMultiLineTextExtent ( " 0 " * 140 )
2015-01-05 05:33:09 -06:00
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 )
2016-07-19 09:30:43 -05:00
self . spellcheck = wx . Button ( panel , - 1 , _ ( " Check &spelling... " ) , size = wx . DefaultSize )
self . unshortenButton = wx . Button ( panel , - 1 , _ ( u " &Expand URL " ) , size = wx . DefaultSize )
2015-01-05 05:33:09 -06:00
self . unshortenButton . Disable ( )
2016-07-19 09:30:43 -05:00
self . translateButton = wx . Button ( panel , - 1 , _ ( u " &Translate... " ) , size = wx . DefaultSize )
cancelButton = wx . Button ( panel , wx . ID_CANCEL , _ ( u " C&lose " ) , size = wx . DefaultSize )
2015-01-05 05:33:09 -06:00
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 )
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 onSelect ( self , ev ) :
self . text . SelectAll ( )
def set_text ( self , text ) :
2015-01-13 12:31:37 -06:00
self . text . ChangeValue ( text )
2015-01-05 05:33:09 -06:00
def get_text ( self ) :
return self . text . GetValue ( )
def text_focus ( self ) :
self . text . SetFocus ( )
2015-03-12 11:45:53 -06:00
def enable_button ( self , buttonName ) :
if getattr ( self , buttonName ) :
return getattr ( self , buttonName ) . Enable ( )