Infinite recursion trying to check all elements of a TreeCtrl

Posted by mavnn on Stack Overflow See other posts from Stack Overflow or by mavnn
Published on 2009-05-13T12:01:18Z Indexed on 2010/05/04 16:38 UTC
Read the original article Hit count: 198

Filed under:
|

I have a TreeCtrl in which more than one Item can be assigned the same object as PyData. When the object is updated, I want to update all of the items in the tree which have that object as their PyData.

I thought the following code would solve the problem quite neatly, but for some reason the logical test (current != self.GetFirstVisibleItem()) always returns true leading to infinite recursion. Can anyone explain why?

def RefreshNodes(self, obj, current=None):
    print "Entered refresh"
    current = current or self.GetFirstVisibleItem()
    if current.IsOk():
        print self.GetPyData(current).name
        if self.GetPyData(current) == obj:
            self.RefreshNode(current)
        current = self.GetNextVisible(current)
        if current != self.GetFirstVisibleItem():
            self.RefreshNodes(obj, current)

Edit: the above is obviously part of a class based on wx.TreeCtrl

© Stack Overflow or respective owner

Related posts about python

Related posts about wxpython