<s> from pyface . action . api import Action , ActionItem , Group , MenuManager , MenuBarManager , ToolBarManager <EOL> from pyface . util . id_helper import get_unique_id <EOL> from traits . api import Bool , Callable , Enum , HasTraits , Instance , List , Property , Str , Trait , Tuple , Unicode <EOL> SubSchema = Trait ( None , Action , ActionItem , Group , MenuManager , <EOL> Instance ( '<STR_LIT>' ) , <EOL> Instance ( '<STR_LIT>' ) , <EOL> Instance ( '<STR_LIT>' ) ) <EOL> class Schema ( HasTraits ) : <EOL> """<STR_LIT>""" <EOL> id = Str <EOL> def _id_default ( self ) : <EOL> return get_unique_id ( self ) <EOL> items = List ( SubSchema ) <EOL> def __init__ ( self , * items , ** traits ) : <EOL> """<STR_LIT>""" <EOL> super ( Schema , self ) . __init__ ( ** traits ) <EOL> self . items . extend ( items ) <EOL> def create ( self , children ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError <EOL> class ActionSchema ( Schema ) : <EOL> """<STR_LIT>""" <EOL> action_factory = Callable ( Action ) <EOL> items = Property ( ) <EOL> def _get_items ( self ) : <EOL> return [ ] <EOL> def create ( self , children ) : <EOL> """<STR_LIT>""" <EOL> traits = dict ( id = self . id ) <EOL> return self . action_factory ( ** traits ) <EOL> class GroupSchema ( Schema ) : <EOL> """<STR_LIT>""" <EOL> group_factory = Callable ( Group ) <EOL> separator = Bool ( True ) <EOL> def create ( self , children ) : <EOL> traits = dict ( id = self . id , separator = self . separator ) <EOL> return self . group_factory ( * children , ** traits ) <EOL> class MenuSchema ( Schema ) : <EOL> """<STR_LIT>""" <EOL> name = Unicode <EOL> action = Instance ( Action ) <EOL> menu_manager_factory = Callable ( MenuManager ) <EOL> def create ( self , children ) : <EOL> traits = dict ( id = self . id , name = self . name ) <EOL> if self . action : <EOL> traits [ '<STR_LIT:action>' ] = self . action <EOL> return self . menu_manager_factory ( * children , ** traits ) <EOL> class MenuBarSchema ( Schema ) : <EOL> """<STR_LIT>""" <EOL> id = '<STR_LIT>' <EOL> menu_bar_manager_factory = Callable ( MenuBarManager ) <EOL> def create ( self , children ) : <EOL> traits = dict ( id = self . id ) <EOL> return self . menu_bar_manager_factory ( * children , ** traits ) <EOL> class ToolBarSchema ( Schema ) : <EOL> """<STR_LIT>""" <EOL> id = '<STR_LIT>' <EOL> name = Unicode ( '<STR_LIT>' ) <EOL> image_size = Tuple ( ( <NUM_LIT:16> , <NUM_LIT:16> ) ) <EOL> orientation = Enum ( '<STR_LIT>' , '<STR_LIT>' ) <EOL> show_divider = Bool ( True ) <EOL> show_tool_names = Bool ( True ) <EOL> tool_bar_manager_factory = Callable ( ToolBarManager ) <EOL> def create ( self , children ) : <EOL> traits = dict ( id = self . id , name = self . name , image_size = self . image_size , <EOL> orientation = self . orientation , <EOL> show_divider = self . show_divider , <EOL> show_tool_names = self . show_tool_names ) <EOL> return self . tool_bar_manager_factory ( * children , ** traits ) <EOL> SGroup = GroupSchema <EOL> SMenu = MenuSchema <EOL> SMenuBar = MenuBarSchema <EOL> SToolBar = ToolBarSchema </s>
