We now have a youtube channel. Subscribe!

Python Tkinter Messagebox Widget



Hello dear readers! welcome back to another section of our tutorial on Python. In this tutorial post, we are going to be discussing about the Tkinter Messagebox Widget.

The Tkinter Messagebox widget is used to display message boxes in your application. The Messagebox widget provides functions that you can use to display an appropriate message.

Some of these functions provided by the Tkinter Messagebox widget are askquestion, askretryignore, showinfo, showerror, askokcancel, showwarning and lastly askyesno.

Syntax

The following below is the syntax for create this widget -

tkMessageBox.FunctionName ( title,  message  [,  options] )

Parameter Details

  • FunctionName - This is the name of the proper message box function.
  • title - This is the text to be displayed in the title bar of a message box.
  • message - This is the text that is to be displayed as a message.
  • options - These are the alternative choices that you use for tailoring a standard message box. Some of the options that you can use are default and parent. Default parent is used to specify the default button, such as ABORT, RETRY, or IGNORE in the message box. The parent option is used in specifying the Window on top of which the message box is to be displayed.


Example

Following is a simple example -

import Tkinter
import tkMessageBox

top = Tkinter.Tk()
def hello():
   tkMessageBox.showinfo("Say Hello", "Hello World")

B1 = Tkinter.Button(top, text = "Say Hello", command = hello)
B1.pack()

top.mainloop()

Output

When the above code is executed, it will produce the following result -



Alright guys! This is where we are rounding up for this tutorial post. In our next tutorial, we are going to be discussing about the Python Tkinter Dimensions.

Feel free to ask your questions where necessary and i will attend to them as soon as possible. If this tutorial was helpful to you, you can use the share button to share this tutorial.

Follow us on our various social media platforms to stay updated with our latest tutorials. You can also subscribe to our newsletter in order to get our tutorials delivered directly to your emails.

Thanks for reading and bye for now.

Post a Comment

Hello dear readers! Please kindly try your best to make sure your comments comply with our comment policy guidelines. You can visit our comment policy page to view these guidelines which are clearly stated. Thank you.
© 2023 ‧ WebDesignTutorialz. All rights reserved. Developed by Jago Desain