Here we are providing basic tutorial in Tkinter
on how to create a message box
in a Tkinter GUI application.
The following Tkinter code will demonstrate the same:
from tkinter import *
root = Tk()
tkinter.messagebox.showinfo("TKinter Messagebox", "Welcome to Tkinter Messagebox")
answer = tkinter.messagebox.askquestion("Question 1", "Are you a programmer?")
if answer == "yes":
In the above code, we imported a class messagebox
from the standard tkinter
Then a function of the same class is invoked in the code known as showinfo()
which is used to create an alert box in the application.
Secondly, a function of the same class is invoked in the code known as askquestion()
which is used to ask a question in the application.
If the answer
is yes, some text is printed on the terminal window as shown below in the output.
After clicking Yes
on Question 1
of above window, the following output comes on the terminal :