Segmented Buttons – Tkinter CustomTkinter 9

In this video we’ll look at Segmented Buttons in CustomTkinter and Python.

Segmented buttons are a group of three switchable buttons.

I’ll show you how to use them, and also how to make them look however you like!

Python Code: ctk_segbutton.py
(Github Code)

from tkinter import *
import customtkinter

customtkinter.set_appearance_mode("dark")  # Modes: system (default), light, dark
customtkinter.set_default_color_theme("dark-blue")  # Themes: blue (default), dark-blue, green

#root = Tk()
root = customtkinter.CTk()

root.title('Tkinter.com - Custom Tkinter Scrollable Frame!')
root.iconbitmap('images/codemy.ico')
root.geometry('700x300')

# Create our function
def clicker(value):
	my_label.configure(text=f'Hello {value}')

# Our button values
my_values = ["John", "April", "Wes"]
# Create the button
my_seg_button = customtkinter.CTkSegmentedButton(root, values=my_values, command=clicker,
	width=300,
	height=100,
	font=("Helvetica",58),
	corner_radius=3,
	border_width=5,
	fg_color="red",
	selected_color="green",
	selected_hover_color="purple",
	unselected_color="pink",
	unselected_hover_color="orange",
	text_color="yellow",
	state="normal",
	text_color_disabled="blue",
	dynamic_resizing=True
	)


my_seg_button.pack(pady=40)

# Set default Selection
#my_seg_button.set("John")

# Label
my_label = customtkinter.CTkLabel(root, text="", font=("Helvetica", 18))
my_label.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...