I inserted several items to the treeview.
Can I lookup the overall number of items which are stored in the treeview ?
Or even better: Can I iterate over all items like for child in tree:...
?
Python 3.X Tkinter 8.6
The treeview has a get_children
method which can get all children for an item. It's a simple matter of calling that method on the root, and then calling it on every item that has children.
This method is documented in the page that you linked to in your question.
Here's a quick example:
def get_all_children(tree, item=""):
children = tree.get_children(item)
for child in children:
children += get_all_children(tree, child)
return children
On my box it took about 15ms to find all items in a tree that had 11,000 items
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With