O'Reilly logo

Python GUI Programming Cookbook by Burkhard A. Meier

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating message boxes – information, warning, and error

A message box is a pop-up window that gives feedback to the user. It can be informational, hinting at potential problems, and even catastrophic errors.

Using Python to create message boxes is very easy.

Getting ready

We will add functionality to the Help | About menu item we created in the previous recipe. The typical feedback to the user when clicking the Help | About menu in most applications is informational. We start with this information and then vary the design pattern to show warnings and errors.

How to do it...

Add the following line of code to the top of the module where the import statements live:

from tkinter import messagebox as mBox

Next, we will create a callback function that will ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required