How to clear an entire Treeview with Tkinter

2019-04-03 17:29发布

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.

2条回答
Emotional °昔
2楼-- · 2019-04-03 17:53

Ok, I found. I post the answer if someone need an answer to my question :

for i in tree.get_children():
    tree.delete(i)
查看更多
神经病院院长
3楼-- · 2019-04-03 17:54

Even simpler:

tree.delete(*tree.get_children())
查看更多
登录 后发表回答