[pygtk] modelfilter visible func

eric texier texiereric at yahoo.com
Sun May 14 01:08:11 WST 2006


I am looking at treemodelfilter.py from the tutorial.
http://www.pygtk.org/pygtk2tutorial/examples/treemodelfilter.py

I was expecting that the function visible_cb will be call for
each rows once per modelfilter.refilter()

I modified the code to count the number of time the callback will
be called (see code bellow) and I realized that 'visible_cb' is
call sometime more than once for each row. Is it a bug or is there a
logic to it that I am missing.
Thanks,
Eric


class ...
....
    def setCount(self,c):
        self.COUNT = c

    def incCount(self):
        self.COUNT = self.COUNT + 1
    def getCount(self):
        return self.COUNT

    # visibility determined by state matching active toggle buttons
    def visible_cb(self, model, iter, data):
        self.COUNT = self.COUNT + 1
        return model.get_value(iter, 1) in data

    # build list of bug states to show and then refilter
    def check_buttons(self, tb):
        self.setCount(0)
        del self.show_states[:]
        for b in self.bbox.get_children():
            if b.get_active():
                self.show_states.append(b.get_label())
        self.modelfilter.refilter()
        print self.getCount()
 


More information about the pygtk mailing list