<s> """<STR_LIT>""" <EOL> import gobject <EOL> import gtk <EOL> class _ListPicker ( gtk . Dialog ) : <EOL> def __init__ ( self , items = ( ) ) : <EOL> gtk . Dialog . __init__ ( self ) <EOL> self . ret = None <EOL> self . _started = <NUM_LIT:0> <EOL> self . connect ( "<STR_LIT>" , self . quit ) <EOL> self . connect ( "<STR_LIT>" , self . quit ) <EOL> self . set_geometry_hints ( min_width = <NUM_LIT> , min_height = <NUM_LIT> ) <EOL> scrolled_win = gtk . ScrolledWindow ( ) <EOL> scrolled_win . set_policy ( gtk . POLICY_AUTOMATIC , gtk . POLICY_AUTOMATIC ) <EOL> scrolled_win . show ( ) <EOL> self . vbox . pack_start ( scrolled_win ) <EOL> button = gtk . Button ( "<STR_LIT>" ) <EOL> button . connect ( "<STR_LIT>" , self . cancel ) <EOL> button . set_flags ( gtk . CAN_DEFAULT ) <EOL> self . action_area . pack_start ( button ) <EOL> button . show ( ) <EOL> ls = gtk . ListStore ( gobject . TYPE_STRING ) <EOL> for item in items : <EOL> iter = ls . append ( ) <EOL> ls . set ( iter , <NUM_LIT:0> , item ) <EOL> lister = gtk . TreeView ( ls ) <EOL> selection = lister . get_selection ( ) <EOL> selection . set_mode ( gtk . SELECTION_BROWSE ) <EOL> selection . unselect_all ( ) <EOL> lister . set_search_column ( <NUM_LIT:0> ) <EOL> scrolled_win . add_with_viewport ( lister ) <EOL> column = gtk . TreeViewColumn ( '<STR_LIT>' , gtk . CellRendererText ( ) , text = <NUM_LIT:0> ) <EOL> lister . append_column ( column ) <EOL> lister . set_headers_visible ( False ) <EOL> lister . connect ( "<STR_LIT>" , self . row_activated ) <EOL> lister . show ( ) <EOL> def cancel ( self , but ) : <EOL> self . ret = None <EOL> self . quit ( but ) <EOL> def quit ( self , * args ) : <EOL> self . hide ( ) <EOL> self . destroy ( ) <EOL> gtk . main_quit ( ) <EOL> def row_activated ( self , lister , path , column ) : <EOL> selection = lister . get_selection ( ) <EOL> value = selection . get_selected ( ) <EOL> if value : <EOL> model , iter = value <EOL> self . ret = model . get_value ( iter , <NUM_LIT:0> ) <EOL> self . quit ( ) <EOL> def list_picker ( items ) : <EOL> win = _ListPicker ( items ) <EOL> win . set_title ( "<STR_LIT>" ) <EOL> win . show ( ) <EOL> gtk . main ( ) <EOL> return win . ret <EOL> class _ColorSelector ( gtk . ColorSelectionDialog ) : <EOL> def __init__ ( self , init ) : <EOL> gtk . ColorSelectionDialog . __init__ ( self , "<STR_LIT>" ) <EOL> self . ret = init <EOL> self . connect ( "<STR_LIT>" , self . quit ) <EOL> self . connect ( "<STR_LIT>" , self . quit ) <EOL> self . get_property ( "<STR_LIT>" ) . connect ( "<STR_LIT>" , self . OK ) <EOL> self . get_property ( "<STR_LIT>" ) . connect ( "<STR_LIT>" , self . quit ) <EOL> self . get_color_selection ( ) . set_current_color ( gtk . gdk . Color ( init ) ) <EOL> def quit ( self , * args ) : <EOL> self . hide ( ) <EOL> self . destroy ( ) <EOL> gtk . main_quit ( ) <EOL> def OK ( self , * args ) : <EOL> col = self . get_color_selection ( ) . get_current_color ( ) <EOL> self . ret = "<STR_LIT>" % ( ( col . red >> <NUM_LIT:8> ) & <NUM_LIT> , ( col . green >> <NUM_LIT:8> ) & <NUM_LIT> , ( col . blue >> <NUM_LIT:8> ) & <NUM_LIT> ) <EOL> self . quit ( ) <EOL> def color_select ( init = "<STR_LIT>" ) : <EOL> win = _ColorSelector ( init ) <EOL> win . show ( ) <EOL> gtk . main ( ) <EOL> return win . ret <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> print list_picker ( dir ( ) ) <EOL> print color_select ( "<STR_LIT>" ) </s>
