Modern Labels and Buttons – Tkinter TTKBootstrap 2

In this video I’ll show you how to create a simple app with TTKBootstrap and Tkinter.

We’ll focus on labels and buttons in this video, and I’ll explain how to use them and their ttkbootstrap attributes.

We’ll also build a simple function with a counter that changes the label text whenever we click a button.

Python Code: tb_intro.py
(Github Code)

from tkinter import *
from ttkbootstrap.constants import *
import ttkbootstrap as tb


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

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


# Create a Function for the Button
counter = 0
def changer():
	global counter
	counter += 1
	if counter % 2 == 0:
		my_label.config(text="Hello World!")
	else:
		my_label.config(text="Goodbye World!")




# Colors:
# Default, primary, secondary, success, info, warning, danger, 
# light, dark


# Create a Label
my_label = tb.Label(text="Hello World!", font=("Helvetica", 28), 
	bootstyle="danger, inverse")
my_label.pack(pady=50)

# Create a Button
my_button = tb.Button(text="Click Me!", 
	bootstyle="success, outline", command=changer)
my_button.pack(pady=20)


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

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...