<s> """<STR_LIT>""" <EOL> from pyjamas . ui . SimplePanel import SimplePanel <EOL> from pyjamas . ui . Tree import Tree <EOL> from pyjamas . ui . TreeItem import TreeItem <EOL> from pyjamas import DOM <EOL> from pyjamas import Window <EOL> class TreeDemo ( SimplePanel ) : <EOL> def __init__ ( self ) : <EOL> SimplePanel . __init__ ( self ) <EOL> tree = Tree ( ) <EOL> tree . addTreeListener ( self ) <EOL> s1 = self . createItem ( "<STR_LIT>" ) <EOL> s1 . addItem ( self . createItem ( "<STR_LIT>" , value = <NUM_LIT:11> ) ) <EOL> s1 . addItem ( self . createItem ( "<STR_LIT>" , value = <NUM_LIT:12> ) ) <EOL> s2 = self . createItem ( "<STR_LIT>" ) <EOL> s2 . addItem ( self . createItem ( "<STR_LIT>" , value = <NUM_LIT> ) ) <EOL> s2 . addItem ( self . createItem ( "<STR_LIT>" , value = <NUM_LIT> ) ) <EOL> s1 . setState ( True , fireEvents = False ) <EOL> s2 . setState ( True , fireEvents = False ) <EOL> tree . addItem ( s1 ) <EOL> tree . addItem ( s2 ) <EOL> self . add ( tree ) <EOL> def createItem ( self , label , value = None ) : <EOL> item = TreeItem ( label ) <EOL> DOM . setStyleAttribute ( item . getElement ( ) , "<STR_LIT>" , "<STR_LIT>" ) <EOL> if value is not None : <EOL> item . setUserObject ( value ) <EOL> return item <EOL> def onTreeItemSelected ( self , item ) : <EOL> value = item . getUserObject ( ) <EOL> Window . alert ( "<STR_LIT>" + str ( value ) ) <EOL> def onTreeItemStateChanged ( self , item ) : <EOL> pass </s>
