How to clear an entire Treeview with Tkinter
45,134
Solution 1
Ok, I found. I post the answer if someone need an answer to my question :
for i in tree.get_children():
tree.delete(i)
Solution 2
Even simpler:
tree.delete(*tree.get_children())
Author by
katze
Updated on July 24, 2021Comments
-
katze almost 3 years
My program uses a
ttk.Treeview
as a table and fills it with many numbers.I want to clear the
ttk.Treeview
when I press a button in the window.Is there a simple way to clear the
ttk.Treeview
?Thanks.
-
buhtz over 6 yearsWhy the
*
there? -
James Adam over 6 yearsIt's the 'splat' operator: see this question
-
Rahul Varadkar over 3 yearsi tried but it didn't delete rows from the tree. Is there any setting missing when tree is created?
-
TheTechRobo Stands for Ukraine about 3 yearsCould you please add a snippet of useful code? It's unlikely, but that answer could sometime be removed, rendering this answer not very helpful. :)