Folks,
I have a wxPython app that uses a wxTreeCtrl. A couple of my functions are
required to traverse the tree and visit every node. I developed it using
Win2k, Python 2.2, wxPython 2.4.0.x and it worked great. I later upgraded
to Python 2.3/wxPython 2.4.2.4 and it still worked great. I tried to use it
under Red Hat 8/Python 2.2/wxPython 2.4.2.4 and it fails. It's not
generating an error, but it's not visiting all the tree nodes.
As an example, I'm using the wxPython wxTreeCtrl demo (but I've reduced the
number of children of the root from 15 to 5). In the constructor, I added a
call to a method I added, self.printTree(self.tree.GetRootItem(), 0). That
method is implemented as follows:
def printTree(self, treeNode, cookie):
'''Recursively traverses a tree and prints the node labels.'''
print "printTree(" + self.tree.GetItemText(treeNode) + ", " +
str(cookie) + ")"
if treeNode:
print "Visiting treeNode", self.tree.GetItemText(treeNode)
print "Checking for child of", self.tree.GetItemText(treeNode)
child, cookie = self.tree.GetFirstChild(treeNode, cookie)
if not child:
print "No child found"
while child:
print "Found child:", self.tree.GetItemText(child)
self.printTree(child, cookie)
print "Checking for additional child of",
self.tree.GetItemText(treeNode)
child, cookie = self.tree.GetNextChild(child, cookie)
if not child:
print "No additional child found"
I intentionally made it verbose to see exactly what was going on. When I
run this under Win2K, it shows that it properly visits all the tree nodes:
Root
0
0-a
0-a-0
0-a-1
0-a-2
0-a-3
0-a-4
0-b
0-b-0
.
.
.
4-e-4 (remember I shortened the tree to only 5 children of the root, 0 thru
4, so this is the end)
However, when I run this same code on my Linux configuration, it only visits
the following nodes:
Root
0
0-a
0-a-0
0-a-1
0-b
0-b-0
0-b-2
then it stops (without signalling any kind of error).
Does anyone have any idea what is causing this? The actual code used to run
this test is attached. It runs from within the demo (just stick the file
into the wxPython/demo dir and add the module name to
wxPython/demo/Main.py).
Thanks.
Paul
MyWxTreeCtrl.py (8.17 KB)