Python Tkinter Treeview

ttk.Treeview displays a hierarchical collection of items and also displays tabular data. We can add child node so can create a view which can be expanded.

  • Tkinter Treeview Basics

from tkinter import ttk
Treeview tree
Here is a basic Treeview with tree.
from tkinter import ttk
import tkinter as tk
# Creating tkinter my_w
my_w = tk.Tk()
# Using treeview widget
trv = ttk.Treeview(my_w, selectmode ='browse')

# column identifiers 
trv["columns"] = ("1", "2")
# Defining headings, other option is tree
trv['show'] = 'tree' 
# width of columns and alignment 
trv.column("#0", width = 80, anchor ='c')
trv.column("1", width = 10, anchor ='c')
trv.column("2", width = 100, anchor ='c')
# Headings  
# respective columns
trv.heading("#0", text ="Label",anchor='c')
trv.heading("1", text ="id")
trv.heading("2", text ="Name",anchor='c')


Watch the column with #0, this column will display in Tree and show the text part given in each row. The line saying trv['show'] = 'tree' can take the value as headings trv['show'] = 'headings' and the column with #0 will be hidden.
Treeview headings

Parent-child node

We can set the parent and child rows or nodes to the Treeview.
Treeview Parent-child nodes
Treeview insert Records of MySQL Pagination of Records of MySQL Delete Records

Post your comments , suggestion , error , requirements etc here

Python Video Tutorials
Python SQLite Video Tutorials
Python MySQL Video Tutorials
Python Tkinter Video Tutorials
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
©2000-2021 All rights reserved worldwide Privacy Policy Disclaimer