[pygtk] Advanced Treeview Filtering Trouble
John Finlay
finlay at moeraki.com
Sat Apr 29 02:58:41 WST 2006
JUAN ERNESTO FLORES BELTRAN wrote:
> John wrote:
>
>> If I understand your question I don't think you need to use the
>> set_modify_func() method. The set_visible_func() method should be
>> sufficient but you have to pass in an object that has mutable
>> contents corresponding to the columns that you want to use for
>> filtering. For example you could create a Python object that has one
>> attribute that contains a list of car models and another attribute
>> that has a maximum price. Pass this object as the data arg to the
>> set_visible_func() method and change the attributes as needed. Your
>> visible_cb() function could then do something like:
>>
>> def visible_cb(self, treestore, iter, x):
>> return treestore[iter][0] in x.models and treestore[iter][4] <=
>> x.maxprice
>>
>> John
>
> It did work!!
> thanks a lot jhon!!...
>
> However a new trouble has shown up!!, now i do need to get the row
> data from the treeview which respond to the set_visible_func()
> method. It is easy to get the data from an ordinary treeview, it can
> be done by "catching" the "cursor_changed" signal and handling it with
> a function as follows:
>
> ---------------------------------------------------------------------------------------------------------------------------------
>
> #the treeview is connected to the signal and this event is connected
> to a signal handler
> self.connection= self.treeview.connect("cursor_changed",
> self.getreedata)
>
> #then the signal handler (a callback) is in charge of getting the
> data of the row
> def self.getreedata(self, iter):
> treeselection = self.treeview.get_selection()
> select= treeselection.get_selected()
> row_value= self.treestore.get_value(select[1], 0)
row_value= select[0].get_value(select[1], 0)
You need to use the model used by the TreeView which is self.modelfilter
I'm assuming.
John
More information about the pygtk
mailing list