From the course: Python GUI Development with Tkinter

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Building a hierarchical treeview

Building a hierarchical treeview

From the course: Python GUI Development with Tkinter

Start my 1-month free trial

Building a hierarchical treeview

- [Instructor] The treeview widget can be used to display a list of items that the user can interact with and make selections from. Those items can be presented on a single level or as part of a multi-tiered hierarchy. To begin, I've already imported my tkinter package, as well as the themed Tk module. And I've created a root window using the Tk constructor method. To create my treeview and store it in a variable called treeview, I'm going to use the ttk Treeview constructor method and I'll pass it the root as the parent. I'll add the treeview to my root window using the pack command. You'll see that the treeview is created here, but it's currently empty. To use it, you need to add one or more items to the tree. Each item represents a node in the tree and can be referenced by a unique item name or id. Those item names and ids can be chosen by the programmer at the time when the item is created or tkinter will automatically generate a unique id itself. To insert an item into the tree…

Contents