MESSAGEBOX IN TKINTER
In this tutorial we are going to learn about the messagebox in tkinter that is used in applications. We will learn about different functions which displays different kinds of popups.
What is MessageBox in Tkinter?
The messagebox is used for showing messages inside the application. There are various functions that can be used for showing required messages depending on when to show them. The syntax for messagebox is:
Messagebox.functionname ( window_title, message, [features] )
Messagebox methods are as follows:
- showinfo()
- showwarning()
- showerror ()
- askquestion()
- askokcancel()
- askyesno ()
- askretrycancel ()
Creating MessageBox
You can create simple a messagebox widget as follows:
from tkinter import * from tkinter import messagebox screen = Tk() screen.geometry('300x300') def click_me(): messagebox.askquestion("Your choice", "Do you want to close?") click = Button(screen, text = "click me", command = click_me) click.pack() screen.mainloop()
Output will be:
For more functionalities of tkinter message box, go here