<s> from pyface . qt import QtGui <EOL> from pyface . action . api import MenuBarManager , StatusBarManager <EOL> from pyface . action . api import ToolBarManager <EOL> from traits . api import Instance , List , on_trait_change , provides , Unicode <EOL> from pyface . i_application_window import IApplicationWindow , MApplicationWindow <EOL> from pyface . image_resource import ImageResource <EOL> from . window import Window <EOL> @ provides ( IApplicationWindow ) <EOL> class ApplicationWindow ( MApplicationWindow , Window ) : <EOL> """<STR_LIT>""" <EOL> icon = Instance ( ImageResource ) <EOL> menu_bar_manager = Instance ( MenuBarManager ) <EOL> status_bar_manager = Instance ( StatusBarManager ) <EOL> tool_bar_manager = Instance ( ToolBarManager ) <EOL> tool_bar_managers = List ( ToolBarManager ) <EOL> title = Unicode ( "<STR_LIT>" ) <EOL> def _create_contents ( self , parent ) : <EOL> panel = QtGui . QWidget ( parent ) <EOL> palette = QtGui . QPalette ( panel . palette ( ) ) <EOL> palette . setColor ( QtGui . QPalette . Window , QtGui . QColor ( '<STR_LIT>' ) ) <EOL> panel . setPalette ( palette ) <EOL> panel . setAutoFillBackground ( True ) <EOL> return panel <EOL> def _create_menu_bar ( self , parent ) : <EOL> if self . menu_bar_manager is not None : <EOL> menu_bar = self . menu_bar_manager . create_menu_bar ( parent ) <EOL> self . control . setMenuBar ( menu_bar ) <EOL> def _create_status_bar ( self , parent ) : <EOL> if self . status_bar_manager is not None : <EOL> status_bar = self . status_bar_manager . create_status_bar ( parent ) <EOL> self . control . setStatusBar ( status_bar ) <EOL> status_bar . setVisible ( self . status_bar_manager . visible ) <EOL> def _create_tool_bar ( self , parent ) : <EOL> tool_bar_managers = self . _get_tool_bar_managers ( ) <EOL> visible = self . control . isVisible ( ) <EOL> for tool_bar_manager in tool_bar_managers : <EOL> tool_bar = tool_bar_manager . create_tool_bar ( parent ) <EOL> self . control . addToolBar ( tool_bar ) <EOL> tool_bar . show ( ) <EOL> if len ( tool_bar . objectName ( ) ) == <NUM_LIT:0> : <EOL> tool_bar . setObjectName ( tool_bar_manager . name ) <EOL> self . control . setVisible ( visible ) <EOL> def _set_window_icon ( self ) : <EOL> if self . icon is None : <EOL> icon = ImageResource ( '<STR_LIT>' ) <EOL> else : <EOL> icon = self . icon <EOL> if self . control is not None : <EOL> self . control . setWindowIcon ( icon . create_icon ( ) ) <EOL> def _size_default ( self ) : <EOL> """<STR_LIT>""" <EOL> return ( <NUM_LIT> , <NUM_LIT> ) <EOL> def _create ( self ) : <EOL> super ( ApplicationWindow , self ) . _create ( ) <EOL> contents = self . _create_contents ( self . control ) <EOL> self . control . setCentralWidget ( contents ) <EOL> self . _create_trim_widgets ( self . control ) <EOL> def _create_control ( self , parent ) : <EOL> control = super ( ApplicationWindow , self ) . _create_control ( parent ) <EOL> control . setObjectName ( '<STR_LIT>' ) <EOL> control . setAnimated ( False ) <EOL> control . setDockNestingEnabled ( True ) <EOL> return control <EOL> def _get_tool_bar_managers ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . tool_bar_manager is not None : <EOL> tool_bar_managers = [ self . tool_bar_manager ] <EOL> else : <EOL> tool_bar_managers = self . tool_bar_managers <EOL> return tool_bar_managers <EOL> def _menu_bar_manager_changed ( self ) : <EOL> if self . control is not None : <EOL> self . _create_menu_bar ( self . control ) <EOL> def _status_bar_manager_changed ( self ) : <EOL> if self . control is not None : <EOL> self . _create_status_bar ( self . control ) <EOL> @ on_trait_change ( '<STR_LIT>' ) <EOL> def _update_tool_bar_managers ( self ) : <EOL> if self . control is not None : <EOL> for child in self . control . children ( ) : <EOL> if isinstance ( child , QtGui . QToolBar ) : <EOL> self . control . removeToolBar ( child ) <EOL> child . deleteLater ( ) <EOL> self . _create_tool_bar ( self . control ) <EOL> def _icon_changed ( self ) : <EOL> self . _set_window_icon ( ) </s>
