In this video we’ll learn about the Treeview Widget for TTKBootstrap and Tkinter.

The treeview widget allows you to create tables with rows and columns of data in Tkinter.

We aren’t going to dive too deeply into the Treeview Widget in this video, I’m just going to show you how to use it with TTKBootstrap.

Python Code: tree_view.py
(Github Code)

from tkinter import *
import ttkbootstrap as tb

root = tb.Window(themename="superhero")

#root = Tk()
root.title("TTK Bootstrap! Treeview")
root.iconbitmap('images/codemy.ico')
root.geometry('700x350')

# Define Columns
columns = ("first_name", "last_name", "email")

# Create Treeview
my_tree = tb.Treeview(root, bootstyle="danger", columns=columns, 
	show="headings")
my_tree.pack(pady=20)

# Define headings
my_tree.heading('first_name', text="First Name")
my_tree.heading('last_name', text="Last Name")
my_tree.heading('email', text="Email Address")

# Create Sample Data
contacts = []

for n in range(1,20):
	contacts.append((f'First {n}', f'Last {n}', f'email{n}@address.com'))

# Add Data To Treeview
for contact in contacts:
	my_tree.insert('', END, values=contact)


root.mainloop()


John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of the first dot com boom. After that he developed the award-winning Submission-Spider search engine submission software that's been used by over 3 million individuals, businesses, and governments in over 42 countries. He's written several Amazon #1 best selling books on coding, and runs a popular Youtube coding channel.

View all posts

Add comment

Your email address will not be published. Required fields are marked *

John Elder

John is the CEO of Codemy.com where he teaches over 100,000 students how to code! He founded one of the Internet's earliest advertising networks and sold it to a publicly company at the height of...