<s> import wx <EOL> import string <EOL> from options import AdvancedOptions <EOL> from message import Message <EOL> try : <EOL> from opentumblr . tumblr import Api <EOL> except ImportError : <EOL> from tumblr import Api <EOL> import wx . lib . filebrowsebutton as filebrowse <EOL> class Photo ( wx . Panel ) : <EOL> def __init__ ( self , parent , id ) : <EOL> wx . Panel . __init__ ( self , parent , id ) <EOL> self . parent = parent <EOL> self . api = self . parent . api <EOL> self . tags = None <EOL> self . date = None <EOL> self . private = <NUM_LIT:0> <EOL> self . p_main = wx . Panel ( self , - <NUM_LIT:1> ) <EOL> self . s_photo_staticbox = wx . StaticBox ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . b_options = wx . Button ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . s_browse_staticbox = wx . StaticBox ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . l_addphoto = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . l_photo = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . b_browse = filebrowse . FileBrowseButton ( self . p_main , - <NUM_LIT:1> ) <EOL> self . l_supports = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . l_photourl = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . tc_photourl = wx . TextCtrl ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . l_caption = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . tc_caption = wx . TextCtrl ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" , style = wx . TE_MULTILINE ) <EOL> self . l_photolink = wx . StaticText ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . tc_photolink = wx . TextCtrl ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . b_create = wx . Button ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . b_cancel = wx . Button ( self . p_main , - <NUM_LIT:1> , "<STR_LIT>" ) <EOL> self . Bind ( wx . EVT_BUTTON , self . AdvancedOptions , id = self . b_options . GetId ( ) ) <EOL> self . Bind ( wx . EVT_BUTTON , self . OnCreatePhoto , id = self . b_create . GetId ( ) ) <EOL> self . Bind ( wx . EVT_BUTTON , self . OnCancel , id = self . b_cancel . GetId ( ) ) <EOL> self . __set_properties ( ) <EOL> self . __do_layout ( ) <EOL> def __set_properties ( self ) : <EOL> self . l_addphoto . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . BOLD , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . l_photo . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . l_supports . SetFont ( wx . Font ( <NUM_LIT:8> , wx . DEFAULT , wx . NORMAL , wx . BOLD , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . l_photourl . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . tc_photourl . SetMinSize ( ( - <NUM_LIT:1> , - <NUM_LIT:1> ) ) <EOL> self . tc_photourl . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . l_caption . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . tc_caption . SetFont ( wx . Font ( <NUM_LIT:15> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . tc_photolink . SetBackgroundColour ( wx . Colour ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) ) <EOL> self . tc_photolink . SetFont ( wx . Font ( <NUM_LIT:11> , wx . DEFAULT , wx . NORMAL , wx . NORMAL , <NUM_LIT:0> , "<STR_LIT>" ) ) <EOL> self . p_main . SetBackgroundColour ( wx . Colour ( <NUM_LIT:255> , <NUM_LIT:255> , <NUM_LIT:255> ) ) <EOL> def __do_layout ( self ) : <EOL> s_main = wx . BoxSizer ( wx . VERTICAL ) <EOL> s_photo = wx . StaticBoxSizer ( self . s_photo_staticbox , wx . VERTICAL ) <EOL> s_buttons = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> s_photolink = wx . BoxSizer ( wx . VERTICAL ) <EOL> s_photourl = wx . BoxSizer ( wx . HORIZONTAL ) <EOL> s_browse = wx . StaticBoxSizer ( self . s_browse_staticbox , wx . HORIZONTAL ) <EOL> s_photo . Add ( self . b_options , <NUM_LIT:0> , wx . ALL | wx . ALIGN_CENTER_HORIZONTAL , <NUM_LIT:2> ) <EOL> s_photo . Add ( self . l_addphoto , <NUM_LIT:0> , wx . ALL | wx . ALIGN_CENTER_VERTICAL , <NUM_LIT:2> ) <EOL> s_photo . Add ( self . l_photo , <NUM_LIT:0> , wx . ALL | wx . ALIGN_CENTER_VERTICAL , <NUM_LIT:2> ) <EOL> s_browse . Add ( self . b_browse , <NUM_LIT:0> , wx . ALL | wx . ALIGN_CENTER_VERTICAL , <NUM_LIT:2> ) <EOL> s_photo . Add ( s_browse , <NUM_LIT:0> , wx . EXPAND , <NUM_LIT:0> ) <EOL> s_photo . Add ( self . l_supports , <NUM_LIT:0> , wx . BOTTOM , <NUM_LIT:20> ) <EOL> s_photourl . Add ( self . l_photourl , <NUM_LIT:0> , wx . ALL , <NUM_LIT:2> ) <EOL> s_photourl . Add ( self . tc_photourl , <NUM_LIT:1> , wx . ALL | wx . EXPAND , <NUM_LIT:2> ) <EOL> s_photo . Add ( s_photourl , <NUM_LIT:0> , wx . EXPAND , <NUM_LIT:0> ) <EOL> s_photo . Add ( self . l_caption , <NUM_LIT:0> , wx . ALL | wx . ALIGN_CENTER_VERTICAL , <NUM_LIT:2> ) <EOL> s_photo . Add ( self . tc_caption , <NUM_LIT:1> , wx . ALL | wx . EXPAND , <NUM_LIT:2> ) <EOL> s_photolink . Add ( self . l_photolink , <NUM_LIT:0> , wx . ALL , <NUM_LIT:2> ) <EOL> s_photolink . Add ( self . tc_photolink , <NUM_LIT:0> , wx . ALL | wx . EXPAND , <NUM_LIT:2> ) <EOL> s_photo . Add ( s_photolink , <NUM_LIT:0> , wx . EXPAND , <NUM_LIT:0> ) <EOL> s_buttons . Add ( self . b_create , <NUM_LIT:1> , wx . LEFT | wx . EXPAND , <NUM_LIT:2> ) <EOL> s_buttons . Add ( self . b_cancel , <NUM_LIT:1> , wx . LEFT | wx . EXPAND , <NUM_LIT:2> ) <EOL> s_photo . Add ( s_buttons , <NUM_LIT:0> , wx . ALL | wx . EXPAND , <NUM_LIT:2> ) <EOL> self . p_main . SetSizer ( s_photo ) <EOL> s_main . Add ( self . p_main , <NUM_LIT:1> , wx . ALL | wx . EXPAND , <NUM_LIT:10> ) <EOL> self . SetSizer ( s_main ) <EOL> s_main . Fit ( self ) <EOL> def AdvancedOptions ( self , evt ) : <EOL> self . options = AdvancedOptions ( self , - <NUM_LIT:1> ) <EOL> self . options . Center ( ) <EOL> if self . options . ShowModal ( ) == wx . ID_OK : <EOL> self . tags = self . options . tc_tag . GetValue ( ) . encode ( '<STR_LIT:utf-8>' ) <EOL> self . tags = string . replace ( self . tags , '<STR_LIT:U+0020>' , '<STR_LIT:U+002C>' ) <EOL> self . date = self . options . tc_date . GetValue ( ) . encode ( '<STR_LIT:utf-8>' ) <EOL> if self . options . cb_publishing . GetValue ( ) == '<STR_LIT>' : <EOL> self . private = <NUM_LIT:1> <EOL> else : <EOL> self . private = <NUM_LIT:0> <EOL> if self . options . cb_publishing . GetValue ( ) == '<STR_LIT>' : <EOL> self . date = '<STR_LIT>' <EOL> self . options . Destroy ( ) <EOL> def OnCreatePhoto ( self , evt ) : <EOL> self . source = self . tc_photourl . GetValue ( ) <EOL> if not self . source : <EOL> self . source = None <EOL> self . data = self . b_browse . GetValue ( ) <EOL> if not self . data : <EOL> self . data = None <EOL> self . caption = self . tc_caption . GetValue ( ) . encode ( '<STR_LIT:utf-8>' ) <EOL> self . click = self . tc_photolink . GetValue ( ) <EOL> if self . source or self . data : <EOL> self . api = Api ( self . api . name , self . api . email , self . api . password , self . private , self . date , self . tags ) <EOL> try : <EOL> self . post = self . api . write_photo ( self . source , self . data , self . caption , self . click ) <EOL> except : <EOL> print "<STR_LIT>" <EOL> self . OnCancel ( self ) <EOL> else : <EOL> Message ( '<STR_LIT>' ) <EOL> def OnCancel ( self , evt ) : <EOL> """<STR_LIT>""" <EOL> self . parent . SetPanel ( None ) </s>
