<s> """<STR_LIT>""" <EOL> from ginga import GingaPlugin <EOL> from ginga . gw import Widgets <EOL> class MyGlobalPlugin ( GingaPlugin . GlobalPlugin ) : <EOL> def __init__ ( self , fv ) : <EOL> """<STR_LIT>""" <EOL> super ( MyGlobalPlugin , self ) . __init__ ( fv ) <EOL> self . active = None <EOL> fv . set_callback ( '<STR_LIT>' , self . add_channel ) <EOL> fv . set_callback ( '<STR_LIT>' , self . delete_channel ) <EOL> fv . set_callback ( '<STR_LIT>' , self . focus_cb ) <EOL> def build_gui ( self , container ) : <EOL> """<STR_LIT>""" <EOL> top = Widgets . VBox ( ) <EOL> top . set_border_width ( <NUM_LIT:4> ) <EOL> vbox , sw , orientation = Widgets . get_oriented_box ( container ) <EOL> vbox . set_border_width ( <NUM_LIT:4> ) <EOL> vbox . set_spacing ( <NUM_LIT:2> ) <EOL> self . msgFont = self . fv . getFont ( "<STR_LIT>" , <NUM_LIT:12> ) <EOL> tw = Widgets . TextArea ( wrap = True , editable = False ) <EOL> tw . set_font ( self . msgFont ) <EOL> self . tw = tw <EOL> fr = Widgets . Frame ( "<STR_LIT>" ) <EOL> fr . set_widget ( tw ) <EOL> vbox . add_widget ( fr , stretch = <NUM_LIT:0> ) <EOL> spacer = Widgets . Label ( '<STR_LIT>' ) <EOL> vbox . add_widget ( spacer , stretch = <NUM_LIT:1> ) <EOL> top . add_widget ( sw , stretch = <NUM_LIT:1> ) <EOL> btns = Widgets . HBox ( ) <EOL> btns . set_spacing ( <NUM_LIT:3> ) <EOL> btn = Widgets . Button ( "<STR_LIT>" ) <EOL> btn . add_callback ( '<STR_LIT>' , lambda w : self . close ( ) ) <EOL> btns . add_widget ( btn , stretch = <NUM_LIT:0> ) <EOL> btns . add_widget ( Widgets . Label ( '<STR_LIT>' ) , stretch = <NUM_LIT:1> ) <EOL> top . add_widget ( btns , stretch = <NUM_LIT:0> ) <EOL> container . add_widget ( top , stretch = <NUM_LIT:1> ) <EOL> def get_channel_info ( self , fitsimage ) : <EOL> chname = self . fv . get_channelName ( fitsimage ) <EOL> channel = self . fv . get_channelInfo ( chname ) <EOL> return channel <EOL> def set_info ( self , text ) : <EOL> self . tw . set_text ( text ) <EOL> def add_channel ( self , viewer , channel ) : <EOL> """<STR_LIT>""" <EOL> self . set_info ( "<STR_LIT>" % ( <EOL> channel . name ) ) <EOL> def delete_channel ( self , viewer , channel ) : <EOL> """<STR_LIT>""" <EOL> self . set_info ( "<STR_LIT>" % ( <EOL> channel . name ) ) <EOL> return True <EOL> def focus_cb ( self , viewer , channel ) : <EOL> """<STR_LIT>""" <EOL> chname = channel . name <EOL> if self . active != chname : <EOL> self . active = chname <EOL> self . set_info ( "<STR_LIT>" % ( <EOL> self . active ) ) <EOL> return True <EOL> def redo ( self , channel , image ) : <EOL> """<STR_LIT>""" <EOL> chname = channel . name <EOL> if self . active == chname : <EOL> imname = image . get ( '<STR_LIT:name>' , '<STR_LIT>' ) <EOL> self . set_info ( "<STR_LIT>" % ( <EOL> imname , chname ) ) <EOL> return True <EOL> def start ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def stop ( self ) : <EOL> """<STR_LIT>""" <EOL> pass <EOL> def close ( self ) : <EOL> self . fv . stop_global_plugin ( str ( self ) ) <EOL> return True <EOL> def __str__ ( self ) : <EOL> """<STR_LIT>""" <EOL> return '<STR_LIT>' </s>
