<s> """<STR_LIT>""" <EOL> from __future__ import absolute_import <EOL> from traits . api import ( Any , Bool , Callable , Enum , Event , Float , Instance , List , Str , <EOL> Trait , TraitPrefixList ) <EOL> from . view_element import ViewElement , ViewSubElement <EOL> from . ui import UI <EOL> from . ui_traits import ( AButton , ATheme , AnObject , Buttons , DockStyle , <EOL> EditorStyle , ExportType , HelpId , Image , SequenceTypes , ViewStatus ) <EOL> from . handler import Handler , default_handler <EOL> from . group import Group <EOL> from . item import Item <EOL> from . include import Include <EOL> AnId = Str ( desc = '<STR_LIT>' ) <EOL> Content = Instance ( Group , desc = '<STR_LIT>' ) <EOL> AModelView = Callable ( desc = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> AHandler = Any ( desc = '<STR_LIT>' ) <EOL> ATitle = Str ( desc = '<STR_LIT>' ) <EOL> AKind = Trait ( '<STR_LIT>' , TraitPrefixList ( <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , <EOL> '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT>' , '<STR_LIT:info>' , '<STR_LIT>' ) , <EOL> desc = '<STR_LIT>' , <EOL> cols = <NUM_LIT:4> ) <EOL> OnApply = Callable ( desc = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> IsResizable = Bool ( False , desc = '<STR_LIT>' ) <EOL> IsScrollable = Bool ( False , desc = '<STR_LIT>' ) <EOL> ImportTypes = List ( Str , desc = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> Width = Float ( - <NUM_LIT> , desc = '<STR_LIT>' ) <EOL> Height = Float ( - <NUM_LIT> , desc = '<STR_LIT>' ) <EOL> XCoordinate = Float ( - <NUM_LIT> , desc = '<STR_LIT>' ) <EOL> YCoordinate = Float ( - <NUM_LIT> , desc = '<STR_LIT>' ) <EOL> CloseResult = Enum ( None , True , False , <EOL> desc = '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> AKeyBindings = Instance ( '<STR_LIT>' , <EOL> desc = '<STR_LIT>' ) <EOL> class View ( ViewElement ) : <EOL> """<STR_LIT>""" <EOL> id = AnId <EOL> content = Content <EOL> menubar = Any <EOL> toolbar = Any <EOL> statusbar = ViewStatus <EOL> buttons = Buttons <EOL> default_button = AButton <EOL> key_bindings = AKeyBindings <EOL> handler = AHandler <EOL> model_view = AModelView <EOL> title = ATitle <EOL> icon = Any <EOL> kind = AKind <EOL> object = AnObject <EOL> style = EditorStyle <EOL> dock = DockStyle <EOL> image = Image <EOL> on_apply = OnApply <EOL> resizable = IsResizable <EOL> scrollable = IsScrollable <EOL> export = ExportType <EOL> imports = ImportTypes <EOL> help_id = HelpId <EOL> x = XCoordinate <EOL> y = YCoordinate <EOL> width = Width <EOL> height = Height <EOL> drop_class = Any <EOL> updated = Event <EOL> close_result = CloseResult <EOL> item_theme = ATheme <EOL> label_theme = ATheme <EOL> ok = Bool ( False ) <EOL> cancel = Bool ( False ) <EOL> undo = Bool ( False ) <EOL> redo = Bool ( False ) <EOL> apply = Bool ( False ) <EOL> revert = Bool ( False ) <EOL> help = Bool ( False ) <EOL> def __init__ ( self , * values , ** traits ) : <EOL> """<STR_LIT>""" <EOL> ViewElement . __init__ ( self , ** traits ) <EOL> self . set_content ( * values ) <EOL> def set_content ( self , * values ) : <EOL> """<STR_LIT>""" <EOL> content = [ ] <EOL> accum = [ ] <EOL> for value in values : <EOL> if isinstance ( value , ViewSubElement ) : <EOL> content . append ( value ) <EOL> elif type ( value ) in SequenceTypes : <EOL> content . append ( Group ( * value ) ) <EOL> elif ( isinstance ( value , basestring ) and <EOL> ( value [ : <NUM_LIT:1> ] == '<STR_LIT:<>' ) and ( value [ - <NUM_LIT:1> : ] == '<STR_LIT:>>' ) ) : <EOL> content . append ( Include ( value [ <NUM_LIT:1> : - <NUM_LIT:1> ] . strip ( ) ) ) <EOL> else : <EOL> content . append ( Item ( value ) ) <EOL> for item in content : <EOL> if isinstance ( item , Item ) : <EOL> content = [ Group ( * content ) ] <EOL> break <EOL> self . content = Group ( container = self , * content ) <EOL> def ui ( self , context , parent = None , kind = None , <EOL> view_elements = None , handler = None , <EOL> id = '<STR_LIT>' , scrollable = None , <EOL> args = None ) : <EOL> """<STR_LIT>""" <EOL> handler = handler or self . handler or default_handler ( ) <EOL> if not isinstance ( handler , Handler ) : <EOL> handler = handler ( ) <EOL> if args is not None : <EOL> handler . set ( ** args ) <EOL> if not isinstance ( context , dict ) : <EOL> context = context . trait_context ( ) <EOL> context . setdefault ( '<STR_LIT>' , handler ) <EOL> handler = context [ '<STR_LIT>' ] <EOL> if self . model_view is not None : <EOL> context [ '<STR_LIT:object>' ] = self . model_view ( context [ '<STR_LIT:object>' ] ) <EOL> self_id = self . id <EOL> if self_id != '<STR_LIT>' : <EOL> if id != '<STR_LIT>' : <EOL> id = '<STR_LIT>' % ( self_id , id ) <EOL> else : <EOL> id = self_id <EOL> if scrollable is None : <EOL> scrollable = self . scrollable <EOL> ui = UI ( view = self , <EOL> context = context , <EOL> handler = handler , <EOL> view_elements = view_elements , <EOL> title = self . title , <EOL> id = id , <EOL> scrollable = scrollable ) <EOL> if kind is None : <EOL> kind = self . kind <EOL> ui . ui ( parent , kind ) <EOL> return ui <EOL> def replace_include ( self , view_elements ) : <EOL> """<STR_LIT>""" <EOL> if self . content is not None : <EOL> self . content . replace_include ( view_elements ) <EOL> def __repr__ ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . content is None : <EOL> return '<STR_LIT>' <EOL> return "<STR_LIT>" % '<STR_LIT:U+002CU+0020>' . join ( <EOL> [ item . __repr__ ( ) for item in self . content . content ] ) </s>
