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())
Share:
45,134
katze
Author by

katze

Updated on July 24, 2021

Comments

  • katze
    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
    buhtz over 6 years
    Why the * there?
  • James Adam
    James Adam over 6 years
    It's the 'splat' operator: see this question
  • Rahul Varadkar
    Rahul Varadkar over 3 years
    i tried but it didn't delete rows from the tree. Is there any setting missing when tree is created?
  • TheTechRobo Stands for Ukraine
    TheTechRobo Stands for Ukraine about 3 years
    Could you please add a snippet of useful code? It's unlikely, but that answer could sometime be removed, rendering this answer not very helpful. :)