<s> '''<STR_LIT>''' <EOL> import sys <EOL> import wx <EOL> from gooey . gui import image_repository , events <EOL> from gooey . gui . lang . i18n import _ <EOL> from gooey . gui . pubsub import pub <EOL> from gooey . gui . util import wx_util <EOL> from gooey . gui . windows import footer , header , layouts <EOL> from gooey . gui . windows . runtime_display_panel import RuntimeDisplay <EOL> YES = <NUM_LIT> <EOL> NO = <NUM_LIT> <EOL> class BaseWindow ( wx . Frame ) : <EOL> '''<STR_LIT>''' <EOL> def __init__ ( self , layout_type ) : <EOL> wx . Frame . __init__ ( self , parent = None , id = - <NUM_LIT:1> ) <EOL> self . SetDoubleBuffered ( True ) <EOL> self . layout_type = layout_type <EOL> self . icon = None <EOL> self . head_panel = None <EOL> self . config_panel = None <EOL> self . runtime_display = None <EOL> self . foot_panel = None <EOL> self . panels = None <EOL> self . _init_properties ( ) <EOL> self . _init_components ( ) <EOL> self . _do_layout ( ) <EOL> self . Bind ( wx . EVT_SIZE , self . onResize ) <EOL> self . Bind ( wx . EVT_CLOSE , self . onClose ) <EOL> @ property <EOL> def window_size ( self ) : <EOL> return self . GetSize ( ) <EOL> @ window_size . setter <EOL> def window_size ( self , size_tuple ) : <EOL> self . SetSize ( size_tuple ) <EOL> @ property <EOL> def window_title ( self ) : <EOL> return self . GetTitle ( ) <EOL> @ window_title . setter <EOL> def window_title ( self , title ) : <EOL> self . SetTitle ( title ) <EOL> @ property <EOL> def heading_title ( self ) : <EOL> return self . head_panel . title <EOL> @ heading_title . setter <EOL> def heading_title ( self , text ) : <EOL> self . head_panel . title = text <EOL> @ property <EOL> def heading_subtitle ( self ) : <EOL> return self . head_panel . subtitle <EOL> @ heading_subtitle . setter <EOL> def heading_subtitle ( self , text ) : <EOL> self . head_panel . subtitle = text <EOL> @ property <EOL> def required_section ( self ) : <EOL> return self . config_panel . main_content . required_section <EOL> @ property <EOL> def optional_section ( self ) : <EOL> return self . config_panel . main_content . optional_section <EOL> @ property <EOL> def progress_bar ( self ) : <EOL> return self . foot_panel . progress_bar <EOL> def set_list_contents ( self , contents ) : <EOL> self . config_panel . sidebar . set_list_contents ( contents ) <EOL> def set_display_font_style ( self , style ) : <EOL> self . runtime_display . set_font_style ( <EOL> wx . MODERN if style == '<STR_LIT>' else wx . DEFAULT ) <EOL> def _init_properties ( self ) : <EOL> self . icon = wx . Icon ( image_repository . program_icon , wx . BITMAP_TYPE_ICO ) <EOL> self . SetIcon ( self . icon ) <EOL> def _init_components ( self ) : <EOL> self . runtime_display = RuntimeDisplay ( self ) <EOL> self . head_panel = header . FrameHeader ( parent = self ) <EOL> self . foot_panel = footer . Footer ( self ) <EOL> self . panels = [ self . head_panel , self . config_panel , self . foot_panel ] <EOL> def _do_layout ( self ) : <EOL> sizer = wx . BoxSizer ( wx . VERTICAL ) <EOL> sizer . Add ( self . head_panel , <NUM_LIT:0> , wx . EXPAND ) <EOL> sizer . Add ( wx_util . horizontal_rule ( self ) , <NUM_LIT:0> , wx . EXPAND ) <EOL> if self . layout_type == layouts . COLUMN : <EOL> self . config_panel = layouts . ColumnLayout ( self ) <EOL> else : <EOL> self . config_panel = layouts . FlatLayout ( self ) <EOL> sizer . Add ( self . config_panel , <NUM_LIT:1> , wx . EXPAND ) <EOL> sizer . Add ( self . runtime_display , <NUM_LIT:1> , wx . EXPAND ) <EOL> self . runtime_display . Hide ( ) <EOL> sizer . Add ( wx_util . horizontal_rule ( self ) , <NUM_LIT:0> , wx . EXPAND ) <EOL> sizer . Add ( self . foot_panel , <NUM_LIT:0> , wx . EXPAND ) <EOL> self . SetSizer ( sizer ) <EOL> self . sizer = sizer <EOL> def freeze ( self ) : <EOL> self . Freeze ( ) <EOL> def thaw ( self ) : <EOL> self . Thaw ( ) <EOL> def enable_stop_button ( self ) : <EOL> self . foot_panel . stop_button . Enable ( ) <EOL> def disable_stop_button ( self ) : <EOL> self . foot_panel . stop_button . Disable ( ) <EOL> def show ( self , * args ) : <EOL> '''<STR_LIT>''' <EOL> self . _set_visibility ( '<STR_LIT>' , * args ) <EOL> def hide ( self , * args ) : <EOL> '''<STR_LIT>''' <EOL> self . _set_visibility ( '<STR_LIT>' , * args ) <EOL> def _set_visibility ( self , action , * args ) : <EOL> '''<STR_LIT>''' <EOL> def _set_visibility ( obj , attrs ) : <EOL> for attr in attrs : <EOL> if hasattr ( obj , attr ) : <EOL> instance = getattr ( obj , attr ) <EOL> getattr ( instance , action ) ( ) <EOL> instance . Layout ( ) <EOL> for panel in [ self , self . head_panel , self . foot_panel , self . config_panel ] : <EOL> _set_visibility ( panel , args ) <EOL> def hide_all_buttons ( self ) : <EOL> self . foot_panel . hide_all_buttons ( ) <EOL> def update_console_async ( self , msg ) : <EOL> wx . CallAfter ( self . runtime_display . append_text , msg ) <EOL> def update_progress_aync ( self , progress , disable_animation = False ) : <EOL> wx . CallAfter ( self . UpdateProgressBar , progress , disable_animation ) <EOL> def onResize ( self , evt ) : <EOL> evt . Skip ( ) <EOL> def onClose ( self , evt ) : <EOL> if evt . CanVeto ( ) : <EOL> evt . Veto ( ) <EOL> pub . send_message ( str ( events . WINDOW_CLOSE ) ) <EOL> def UpdateProgressBar ( self , value , disable_animation = False ) : <EOL> pb = self . foot_panel . progress_bar <EOL> if value < <NUM_LIT:0> : <EOL> pb . Pulse ( ) <EOL> else : <EOL> value = min ( int ( value ) , pb . GetRange ( ) ) <EOL> if pb . GetValue ( ) != value : <EOL> if disable_animation and sys . platform . startswith ( "<STR_LIT>" ) : <EOL> if pb . GetRange ( ) == value : <EOL> pb . SetValue ( value ) <EOL> pb . SetValue ( value - <NUM_LIT:1> ) <EOL> else : <EOL> pb . SetValue ( value + <NUM_LIT:1> ) <EOL> pb . SetValue ( value ) <EOL> def show_dialog ( self , title , content , style ) : <EOL> dlg = wx . MessageDialog ( None , content , title , style ) <EOL> result = dlg . ShowModal ( ) <EOL> dlg . Destroy ( ) <EOL> return result <EOL> def show_missing_args_dialog ( self ) : <EOL> self . show_dialog ( _ ( '<STR_LIT>' ) , _ ( '<STR_LIT>' ) , wx . ICON_ERROR ) <EOL> def confirm_exit_dialog ( self ) : <EOL> result = self . show_dialog ( _ ( '<STR_LIT>' ) , _ ( '<STR_LIT>' ) , wx . YES_NO ) <EOL> return result == YES <EOL> def confirm_stop_dialog ( self ) : <EOL> result = self . show_dialog ( _ ( '<STR_LIT>' ) , _ ( '<STR_LIT>' ) , wx . YES_NO ) <EOL> return result == YES <EOL> if __name__ == '<STR_LIT:__main__>' : <EOL> pass </s>
