Logo Search packages:      
Sourcecode: quickly-widgets version File versions  Download package

def widgets::grid_filter::FilterRow::__init__ (   self,
  grid,
  removable = True,
  filter_hints = {} 
)

Create a FilterRow to be used in a GridFilter.
A FitlerRow is comprised of a combo that lists the treeview headings.
The combo stores the string to display for the heading, as well as
the widget that is used to filter each heading. When the user changes
the value in the dropdown, the FilterRow retrieves the correct filter from
the combo, and displays that filter to the user.

The FilterRow also handles offering UI for the user to add and remove
FilterRows for the GridFilter containing it.
 
arguments:
headings -- a tuple of lists of column headers associated with the 
treeview. Each list includes a string for the column title, a constructor
for a widget that supports filtering (such as StringFilter or NumericFilter)
and a zero-based position index for the specific column in the treeview that
will position the header. 
treeview -- the treeview to be filtered. 

keyword arguments:
removable -- bool if the row should be able to be removed from the GridFilter
           Typicall False for the first row.

Definition at line 130 of file grid_filter.py.

00130                                                        {}):
  """Create a FilterRow to be used in a GridFilter.
  A FitlerRow is comprised of a combo that lists the treeview headings.
  The combo stores the string to display for the heading, as well as
  the widget that is used to filter each heading. When the user changes
  the value in the dropdown, the FilterRow retrieves the correct filter from
  the combo, and displays that filter to the user.

  The FilterRow also handles offering UI for the user to add and remove
  FilterRows for the GridFilter containing it.
     
  arguments:
  headings -- a tuple of lists of column headers associated with the 
  treeview. Each list includes a string for the column title, a constructor
  for a widget that supports filtering (such as StringFilter or NumericFilter)
  and a zero-based position index for the specific column in the treeview that
  will position the header. 
  treeview -- the treeview to be filtered. 

  keyword arguments:
  removable -- bool if the row should be able to be removed from the GridFilter
               Typicall False for the first row.
  """
  gtk.HBox.__init__( self, False, 10 )
  self.store = grid.get_model()
  self.grid = grid

  heading_combo_store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_PYOBJECT,gobject.TYPE_INT)

  #apply default combos
  for i, k in enumerate(self.grid.keys):
   if k in filter_hints:
    filt_combo = filter_hints[k]
   else:
    filt_combo = grid.get_columns()[i].default_filter()
         
   heading_combo_store.append([k,filt_combo,i])

   filt_combo.connect("changed",self.__filter_changed)
   filt_combo.show()
 
  self.column_combo = gtk.ComboBox(heading_combo_store)
  cell = gtk.CellRendererText()
  self.column_combo.pack_start(cell, True)
  self.column_combo.add_attribute(cell, 'text', 0)

  self.filter_space = gtk.HBox(False,1)
  self.filter_space.show()

  self.filter_entry = gtk.Entry()
  self.filter_entry.show()
  self.filter_entry.connect("changed",self.__filter_changed)

  self.column_combo.show()
  self.pack_start(self.column_combo,False, False)
  self.column_combo.connect("changed",self.__column_changed)
  self.column_combo.set_active(0)

  self.pack_start(self.filter_space, False, False)
  self.pack_start(self.filter_entry, False)


  button_box = gtk.HBox(False,2)
  button_box.show()
  self.pack_start(button_box,False,False)

  #add a button that can create a new row in the grid filter
  add_button = gtk.Button(stock = gtk.STOCK_ADD)
  add_button.show()
  button_box.pack_start(add_button)
  add_button.connect("clicked",lambda x: self.emit('add_row_requested',self) )

  #add a button to remove the row if applicable
  if removable:
   rm_button = gtk.Button(stock = gtk.STOCK_REMOVE)
   rm_button.show()
   rm_button.connect('clicked', lambda x: self.emit("remove_row_requested",self) )
   button_box.pack_start(rm_button)


Generated by  Doxygen 1.6.0   Back to index