<s> import pygtk <EOL> pygtk . require ( '<STR_LIT>' ) <EOL> import gtk <EOL> bugdata = """<STR_LIT>""" <EOL> class TreeModelFilterExample : <EOL> def delete_event ( self , widget , event , data = None ) : <EOL> gtk . main_quit ( ) <EOL> return False <EOL> def __init__ ( self ) : <EOL> self . window = gtk . Window ( gtk . WINDOW_TOPLEVEL ) <EOL> self . window . set_title ( "<STR_LIT>" ) <EOL> self . window . set_size_request ( <NUM_LIT> , <NUM_LIT> ) <EOL> self . window . connect ( "<STR_LIT>" , self . delete_event ) <EOL> self . liststore = gtk . ListStore ( int , str , str ) <EOL> self . modelfilter = self . liststore . filter_new ( ) <EOL> self . treeview = gtk . TreeView ( ) <EOL> self . treeview . columns = [ None ] * <NUM_LIT:3> <EOL> self . treeview . columns [ <NUM_LIT:0> ] = gtk . TreeViewColumn ( '<STR_LIT>' ) <EOL> self . treeview . columns [ <NUM_LIT:1> ] = gtk . TreeViewColumn ( '<STR_LIT>' ) <EOL> self . treeview . columns [ <NUM_LIT:2> ] = gtk . TreeViewColumn ( '<STR_LIT>' ) <EOL> self . states = [ ] <EOL> for line in bugdata . split ( '<STR_LIT:\n>' ) : <EOL> l = line . split ( ) <EOL> self . liststore . append ( [ int ( l [ <NUM_LIT:0> ] ) , l [ <NUM_LIT:1> ] , '<STR_LIT:U+0020>' . join ( l [ <NUM_LIT:2> : ] ) ] ) <EOL> if not l [ <NUM_LIT:1> ] in self . states : <EOL> self . states . append ( l [ <NUM_LIT:1> ] ) <EOL> self . show_states = self . states [ : ] <EOL> self . modelfilter . set_visible_func ( self . visible_cb , self . show_states ) <EOL> self . treeview . set_model ( self . modelfilter ) <EOL> for n in range ( <NUM_LIT:3> ) : <EOL> self . treeview . append_column ( self . treeview . columns [ n ] ) <EOL> self . treeview . columns [ n ] . cell = gtk . CellRendererText ( ) <EOL> self . treeview . columns [ n ] . pack_start ( self . treeview . columns [ n ] . cell , <EOL> True ) <EOL> self . treeview . columns [ n ] . set_attributes ( <EOL> self . treeview . columns [ n ] . cell , text = n ) <EOL> self . treeview . set_search_column ( <NUM_LIT:3> ) <EOL> self . vbox = gtk . VBox ( ) <EOL> self . scrolledwindow = gtk . ScrolledWindow ( ) <EOL> self . bbox = gtk . HButtonBox ( ) <EOL> self . vbox . pack_start ( self . scrolledwindow ) <EOL> self . vbox . pack_start ( self . bbox , False ) <EOL> for state in self . states : <EOL> b = gtk . ToggleButton ( state ) <EOL> self . bbox . pack_start ( b ) <EOL> b . set_active ( True ) <EOL> b . connect ( '<STR_LIT>' , self . check_buttons ) <EOL> self . scrolledwindow . add ( self . treeview ) <EOL> self . window . add ( self . vbox ) <EOL> self . window . show_all ( ) <EOL> return <EOL> def visible_cb ( self , model , iter , data ) : <EOL> return model . get_value ( iter , <NUM_LIT:1> ) in data <EOL> def check_buttons ( self , tb ) : <EOL> del self . show_states [ : ] <EOL> for b in self . bbox . get_children ( ) : <EOL> if b . get_active ( ) : <EOL> self . show_states . append ( b . get_label ( ) ) <EOL> self . modelfilter . refilter ( ) <EOL> return <EOL> def main ( ) : <EOL> gtk . main ( ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> tmfexample = TreeModelFilterExample ( ) <EOL> main ( ) </s>
