Working with message boxes
Now, let's complete the code for the About and Help menus. The functionality is simple. When a user clicks on the Help or About menu, a message window pops up and waits for the user to respond by clicking on a button. Though we can easily code new Toplevel windows to show the About and Help messages, we will instead use a module called messagebox
to achieve this functionality.
The messagebox
module provides ready-made message boxes to display a wide variety of messages in applications. The functions available through this module include showinfo
, showwarning
, showerror
, askquestion
, askokcancel
, askyesno
, askyesnocancel
, and askretrycancel
, as shown in the following screenshot:
To use this module, we simply import it into the current namespace by using the following command:
import tkinter.messagebox
A demonstration of the commonly used functions of messagebox
is illustrated in 2.08.py
in the code bundle. The following are some common usage patterns:
import tkinter...