Color Chooser for TTKBootstrap – Tkinter TTKBootstrap 21

In this video we’ll look at the Color Chooser for TTKBootstrap, Tkinter, and Python.

The Color Chooser Dialog is a pop up dialog that allows you to pick a color.

It then returns that color as a hex code, and RGB value, or an HSLK value.

Python Code: cc.py
(Github Code)

from tkinter import *
import ttkbootstrap as tb
from ttkbootstrap.dialogs.colorchooser import ColorChooserDialog


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

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

def cc():
	# Create Color Chooser
	my_color = ColorChooserDialog()
	# Show Color Chooser
	my_color.show()
	# Return Color Chooser Info
	colors = my_color.result
	# Output to the label  (.hex .hsl .rgb)
	my_label.config(text=colors.hex)
	# Change the bg color of our app to chosen color
	root.configure(background=colors.hex)



my_button = tb.Button(root, text="Click Me!", bootstyle="danger", command=cc)
my_button.pack(pady=40)

my_label = tb.Label(root, text="", font=("Helvetica", 18))
my_label.pack(pady=10)




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