Python 如何使用 Tkinter 清除整个 Treeview
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22812134/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to clear an entire Treeview with Tkinter
提问by katze
My program uses a ttk.Treeview
as a table and fills it with many numbers.
我的程序使用 attk.Treeview
作为表格并用许多数字填充它。
I want to clear the ttk.Treeview
when I press a button in the window.
ttk.Treeview
当我按下窗口中的按钮时,我想清除它。
Is there a simple way to clear the ttk.Treeview
?
有没有简单的清除方法ttk.Treeview
?
Thanks.
谢谢。
采纳答案by katze
Ok, I found. I post the answer if someone need an answer to my question :
好的,我找到了。如果有人需要我的问题的答案,我会发布答案:
for i in tree.get_children():
tree.delete(i)
回答by James Adam
Even simpler:
更简单:
tree.delete(*tree.get_children())