In this video I’ll show you how to Messages Boxes with TTKBootstrap and Tkinter.

MessageBox in TTKBootstrap and Tkinter is super important. I’ll show you how to create them in this video.

I’ll also show you how to add a custom icon to the popup box.

There are several message boxes, we’ll look at: yesno, ok, okcancel, show_info, show_error, show_question, show_warning, yesnocancel, and retrycancel.

Python Code: mbox.py
(Github Code)

from tkinter import *
import ttkbootstrap as tb
from ttkbootstrap.dialogs import Messagebox

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

#root = Tk()
root.title("TTK Bootstrap! Message Box")
# Main App Icon
root.iconbitmap('images/codemy.ico')
# Message Box Icon
root.iconbitmap(default='images/codemy.ico')
root.geometry('700x350')

def clicker():
	# create a dialog
	# yesno, ok, okcancel, show_info, show_error, show_question
	# show_warning, yesnocancel, retrycancel
	mb = Messagebox.retrycancel("Display Some Message Here", "Here is the Title")

	#if mb == "No":
	#	print("no")
	#else:
	#	print("yes")
	
	# Display button click
	my_label.config(text=f'You Clicked {mb}')


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

my_label = tb.Label(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

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