如何在树中按名称获取树cntrl项目?
这是我尝试过的:
def get_item_by_label(tree, search_text, root_item):
#searching the item by name and returns it
item, cookie = tree.GetFirstChild(root_item)
while item.IsOk():
text = tree.GetItemText(item)
if text.lower() == search_text.lower():
return item
if tree.ItemHasChildren(item):
match = get_item_by_label(tree, search_text, item)
if match.IsOk():
return match
item, cookie = tree.GetNextChild(root_item, cookie)
return root_item