Re: [pygtk] Advanced Treeview Filtering Trouble

2006-04-27 Thread JUAN ERNESTO FLORES BELTRAN
Thanks a lot!

it did work!!

:)


-- 
http://mail.python.org/mailman/listinfo/python-list


fwd: Advanced Treeview Filtering Help

2006-04-27 Thread JUAN ERNESTO FLORES BELTRAN
by the way, iam using pygtk to develop the GUI
Regards.-


-- 
http://mail.python.org/mailman/listinfo/python-list


Advanced Treeview Filtering Help

2006-04-27 Thread JUAN ERNESTO FLORES BELTRAN
Hi you all,

I am developping a python application which connects to a database 
(postresql) and displays the query results on a treeview. In adittion to 
displaying the info i do need to implement filtering facility for all the 
columns of the treestore/liststore model in order to allow the user an easy 
search method to find the desired information.

The treestore is created with information related to cars, the columns are:

car_model   car_year   car_color   car_type  car_price
chevrolet  1998   white   sedan 5.000 US$
ford 1996blue sedan 3.000 US$
  - - --   -
  - - --   -
  - - --   -

I have been able to allow filtering to only one column,  an extract of my 
code as follows:



   #treestore creation
   self.treestore = gtk.TreeStore(str, str, str, str, str)
   self.modelfilter = self.treestore.filter_new()
   self.treeview=gtk.TreeView()

   #append treestore columns
   self.treestore.append(None, [self.model, self.year, self.color, 
self.type,  self.price]

   #set treestore model to allow filtering by car_model column
   self.modelfilter.set_visible_func(self.visible_cd, self.car_model)

#the function to filter the treestore
def visible_cb(self, treestore, iter, x)
  return treestore.get_value(iter, 0) in x

#self.car_model is a list of items wich change according to user needs and 
can be controlled by  a #secundary treeview or a button  this function is 
not explained.



The code mentioned above does work but i can only fllter  by defining 
criterias in the first column. To allow filtering to all the columns i do 
need the following code to work:

-
treemodelfilter.set_modify_func(types, func, data=None)
def func(model, iter, column, user_data)
-

where types should be:
types = (str, str, str, str, str)

the function to allow filtering:
def visible_cb(self, treestore, column, iter, x)
  return treestore.get_value(iter, column) in x

and the rest of the code never changes...however it is not woking. Any 
suggestion about the code mention?? am i making mistakes?? where?? do i have 
to pass the column number someway to the visible_cb function??? how??

can any of you suggest a code example to follow and find out how the 
treeview must be coded in order to allow "multicolumn filtering"???

thanks in advance for your support..
Juan


-- 
http://mail.python.org/mailman/listinfo/python-list