In this video we’ll look at MenuButtons in TTKBootstrap, Tkinter, and Python.

Menu buttons are nice drop down combo button type menus for TTKBootstrap.

I’ll show you how to create them in this video, and how to make them do things too!

Python Code: menu_button.py
(Github Code)

from tkinter import *
import ttkbootstrap as tb


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

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

def stuff(x):
	my_menu.config(bootstyle=x)
	my_label.config(text=f'You Selected {x}')


my_menu = tb.Menubutton(root, bootstyle="warning", text="Things!")
my_menu.pack(pady=50)

# Create basic menu
inside_menu = tb.Menu(my_menu)

# Add Items To Our Inside Menu
item_var = StringVar()
for x in ['primary', 'secondary', 'danger', 'info', 'outline primary', 'outline secondary', 'outline danger', 'outline info']:
	inside_menu.add_radiobutton(label=x, variable=item_var, command=lambda x=x: stuff(x))

# Associate the inside menu with the menubutton
my_menu['menu'] = inside_menu

# Create a label
my_label = tb.Label(root, text="")
my_label.pack(pady=40)


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