Tkinter messagebox

  • Post category:Tkinter

In this Tkinter tutorial, you will learn how to add the Tkinter messagebox.

# import Tkinter Module
import tkinter as tk

# import messagebox
from tkinter import messagebox

# create main window
var = tk.Tk()

# Set title
var.title("My Tkinter")

# create a function
def my_fun():

    # show message
    messagebox.showinfo("Title of Box", "This Message will show")

# create a button
var2 = tk.Button(var, text="Click Me, First button", fg="white", bg="blue", command=my_fun)

# pack button
var2.grid(row=0, column=0)

# start the event loop


Free resources to learn advanced skills: AiHints and CodeAllow