Tkinter messagebox - Show Info
Tkinter messagebox – Show info
In Tkinter, the messagebox.showinfo() method is used display or show an information in a window or message box.
In this tutorial, you will learn how to display an information message to user using messagebox.showinfo() method in Tkinter, how an information message box is displayed in different operating systems, and an example program.
Syntax of messagebox.showinfo()
The syntax of showinfo() method is
messagebox.showinfo(title, message)
where
Parameter | Description |
---|---|
title | This string is displayed as title of the message box. [How a title is displayed in message box depends on the Operating System. ] |
message | This string is displayed as information inside the message box. |
How messagebox.showinfo() displays in different Operating Systems
The following screenshots show how an information message box appears in different operating systems.
messagebox.showinfo("Greeting", "Welcome to PythonExamples.org")
In Windows
Given title is displayed as the title of message box. Inside the message box, an info icon (white i mark with blue background in circular shape) is followed by the message.
In MacOS
When you click on the OK button under the message, the message box disappears.
Examples
1. Show a welcome message
For example, consider that you have created a GUI application using Python Tkinter, and you would like to display a greeting message.
You can display the greeting message as an information in a message box, as shown in the following code.
Python Program
import tkinter as tk
from tkinter import messagebox
# Create the main window
window = tk.Tk()
# Show an information message box
messagebox.showinfo("Greeting", "Welcome to PythonExamples.org")
# Run the application
window.mainloop()
Once the message box is displayed, you can click on the OK button. Then the message box disappears.
Output
In Windows 10
In MacOS.
Summary
In this Python Tkinter tutorial, we learned how to display information in message box in Tkinter, with examples.