The tkMessageBox module is utilized to exhibit message boxes in your applications. This unit offers a number of meanings that you can utilize to present a proper message. Some of these meanings are showinfo, showwarning, showerror, askquestion, askokcancel, askyesno, and askretryignore.
Here is the simple syntax to create this widget:
tkMessageBox.FunctionName(title, message [, options])
FunctionName − This is the name of the appropriate message box function.
title − This is the text to be displayed in the title bar of a message box.
message − This is the text to be displayed as a message.
options − options are alternative choices that you may use to tailor a standard message box. Some of the options that you can use are default and parent. The default option is used to specify the default button, such as ABORT, RETRY, or IGNORE in the message box. The parent option is used to specify the window on top of which the message box is to be displayed.
You could use one of the following functions with dialogue box −
- showerror ()
- askyesno ()
- askretrycancel ()
Try the following example yourself −
top = Tkinter.Tk()
tkMessageBox.showinfo("Say Hello", "Hello World")
B1 = Tkinter.Button(top, text = "Say Hello", command = hello)
When the above code is executed, it produces the following result:
Here at Intellinuts, we have created a complete Python tutorial for Beginners to get started in Python.