Recursively expand all branches ox wxTreeCtrl
Josiah Carlson
jcarlson at uci.edu
Sun Apr 4 14:40:43 EDT 2004
Try the following modifications...
def OnPopup1(self,event):
item = self.Tree.GetSelection()
self.parent.msgbox(self,self.Tree.GetItemText(item),"Kein
Titel",wxOK)
#self.Tree.Expand(item)
* self.ExpandCompleteBranch(self.Tree,item,wxNewId())
def ExpandCompleteBranch(self,tree,treeitem,cookie):
self.parent.msgbox(self,"Durchlauf "+str(cookie),"Kein Titel",wxOK)
if tree.ItemHasChildren(treeitem):
lastchild = tree.GetLastChild(treeitem)
tree.Expand(treeitem)
(child,cookie) = tree.GetFirstChild(treeitem,cookie)
self.ExpandCompleteBranch(tree,child,cookie+1)
while child != lastchild:
* #cookie = cookie + 1
(child,cookie) = tree.GetNextChild(treeitem,cookie)
* self.ExpandCompleteBranch(tree,child,wxNewId())
I use wxNewId() for cookie ids so that all calls will have unique cookie
ids. I'm not sure this is technically necessary, but it can't hurt.
Also, by altering the cookie id during the while loop, you are
destroying the cookie that is necessary to access the remainder of the
branch.
Give the above (without the '*' at the beginning of the line) a try.
- Josiah
More information about the Python-list
mailing list