469,917 Members | 1,703 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,917 developers. It's quick & easy.

Advanced Treeview Filtering Help

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 1996 blue 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
Apr 27 '06 #1
2 2623
JUAN ERNESTO FLORES BELTRAN napisał(a):
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..


Your question was answered on PyGTK mailing list. Please, don't crosspost.

--
Jarek Zgoda
http://jpa.berlios.de/
Apr 27 '06 #2
Your question was answered on PyGTK mailing list. Please, don't crosspost.


Where is the pygtk mailing list?

Apr 28 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Joe | last post: by
8 posts views Thread by Matt MacDonald | last post: by
1 post views Thread by doemon | last post: by
reply views Thread by John Smith | last post: by
reply views Thread by Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post: by
reply views Thread by Andrew Meador - ASCPA, MCSE, MCP+I, Network+, A+ | last post: by
reply views Thread by =?Utf-8?B?QnJpYW4gTmljaG9sc29u?= | last post: by
1 post views Thread by Waqarahmed | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.