<s> from pyjamas import DOM <EOL> from pyjamas import Factory <EOL> from pyjamas . ui . SimplePanel import SimplePanel <EOL> class CaptionPanel ( SimplePanel ) : <EOL> """<STR_LIT>""" <EOL> _props = [ ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" , None ) , <EOL> ] <EOL> def __init__ ( self , caption , widget = None , ** kwargs ) : <EOL> if kwargs . has_key ( '<STR_LIT>' ) : <EOL> element = kwargs . pop ( '<STR_LIT>' ) <EOL> else : <EOL> element = DOM . createElement ( "<STR_LIT>" ) <EOL> self . legend = DOM . createElement ( "<STR_LIT>" ) <EOL> DOM . appendChild ( element , self . legend ) <EOL> kwargs [ '<STR_LIT>' ] = caption <EOL> if widget is not None : <EOL> kwargs [ '<STR_LIT>' ] = widget <EOL> if not '<STR_LIT>' in kwargs : <EOL> kwargs [ '<STR_LIT>' ] = '<STR_LIT>' <EOL> SimplePanel . __init__ ( self , element , ** kwargs ) <EOL> @ classmethod <EOL> def _getProps ( self ) : <EOL> return SimplePanel . _getProps ( ) + self . _props <EOL> def getCaption ( self ) : <EOL> return self . caption <EOL> def setCaption ( self , caption ) : <EOL> self . caption = caption <EOL> if caption is not None and not caption == "<STR_LIT>" : <EOL> DOM . setInnerHTML ( self . legend , caption ) <EOL> DOM . insertChild ( self . getElement ( ) , self . legend , <NUM_LIT:0> ) <EOL> elif DOM . getParent ( self . legend ) is not None : <EOL> DOM . removeChild ( self . getElement ( ) , self . legend ) <EOL> Factory . registerClass ( '<STR_LIT>' , '<STR_LIT>' , CaptionPanel ) </s>
