This recipe allows you to iterate over the children of an item in a wxTreeCtrl without having to fool around with GetFirstChild/GetNextChild/cookie boilerplate.
1 2 3 4 5 6 7 8 9 10 | def iterchildren(treectrl, node):
cid, citem = treectrl.GetFirstChild(node)
while cid.IsOk():
yield cid
cid, citem = treectrl.GetNextChild(node, citem)
# sample usage
for i in iterchildren(myTreeControl, someNode):
print myTreeControl.GetItemText(i)
|
I wrote this generator to avoid the copying/pasting/editing of boilerplate code to iterate over the children of an item in a wxTreeCtrl. Since I haven't run across a similar example, I thought I'd share it here.