<s> from pyjamas import DOM <EOL> from pyjamas import Factory <EOL> from pyjamas . ui . Widget import Widget <EOL> class Composite ( Widget ) : <EOL> def __init__ ( self , widget = None , ** kwargs ) : <EOL> self . widget = None <EOL> self . attached = None <EOL> if widget is not None : <EOL> self . initWidget ( widget ) <EOL> Widget . __init__ ( self , ** kwargs ) <EOL> def initWidget ( self , widget ) : <EOL> if self . widget is not None : <EOL> return <EOL> widget . removeFromParent ( ) <EOL> self . setElement ( widget . getElement ( ) ) <EOL> self . widget = widget <EOL> widget . setParent ( self ) <EOL> def isAttached ( self ) : <EOL> if self . widget is not None : <EOL> return self . widget . isAttached ( ) <EOL> return False <EOL> def onAttach ( self ) : <EOL> self . widget . onAttach ( ) <EOL> DOM . setEventListener ( self . getElement ( ) , self ) ; <EOL> self . onLoad ( ) <EOL> def onDetach ( self ) : <EOL> self . widget . onDetach ( ) <EOL> def setWidget ( self , widget ) : <EOL> self . initWidget ( widget ) <EOL> def onBrowserEvent ( self , event ) : <EOL> Widget . onBrowserEvent ( self , event ) <EOL> self . widget . onBrowserEvent ( event ) <EOL> Factory . registerClass ( '<STR_LIT>' , '<STR_LIT>' , Composite ) </s>
