Coding Tutorials Hub

Learn coding with simple code, clear explanations, and examples

Python TKinter GUI - Messagebox Widget

📄 Code


import tkinter as tk
from tkinter import messagebox

def show_alert():
    # Show popup alert
    messagebox.showinfo("Alert", "This is a popup alert")

# Create the main window
root = tk.Tk()
root.title("Tkinter-GUI Messagebox Tutorial")
root.geometry("500x100")

# Create a button
button = tk.Button(root, text="Click to show popup alert", command=show_alert)
button.pack(pady=5)

# Run the application
root.mainloop()

        
💡 Output