Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to clear an entire Treeview with Tkinter

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.

like image 211
katze Avatar asked Apr 02 '14 12:04

katze


People also ask

How do you clear the screen in tkinter?

While creating a canvas in tkinter, it will effectively eat some memory which needs to be cleared or deleted. In order to clear a canvas, we can use the delete() method. By specifying “all”, we can delete and clear all the canvas that are present in a tkinter frame.

How do I disable Treeview in Python?

The Treeview widget is used to display a list of items with more than one feature in the form of columns. By default, the listed items in a Treeview widget can be selected multiple times, however you can disable this feature by using selectmode="browse" in the Treeview widget constructor.

What is Treeview in tkinter?

Introduction to the Tkinter Treeview widgetA Treeview widget allows you to display data in both tabular and hierarchical structures. To create a Treeview widget, you use the ttk.Treeview class: tree = ttk.Treeview(container, **options) A Treeview widget holds a list of items. Each item has one or more columns.


1 Answers

Even simpler:

tree.delete(*tree.get_children()) 
like image 85
James Adam Avatar answered Sep 18 '22 18:09

James Adam