find item in wx.TreeListCtrl by pydata code snippet

Johannes Lochmann johannes.lochmann at googlemail.com
Fri Aug 18 05:38:04 EDT 2006


Hello list,

here is a small code snippet to recursively search a wx.TreeListCtrl for an 
item with specific pydata.

Feel free to comment!


def recursiveFindItemByPydata(self, parent, pydata):
    item, cookie = self.GetFirstChild(parent)
    while item:
        if self.GetPyData(item) == pydata:
                return item
                                
        if self.ItemHasChildren(item):
            found = self.recursiveFindItemByPydata(item, pydata)
            if found is not None:
                return found
              
        item, cookie = self.GetNextChild(parent, cookie)
    return None

HAND

Johannes



More information about the Python-list mailing list