Implementing Tkinter dialogs
Tkinter contains a number of submodules that provide ready-made dialog windows for different situations. These include:
messagebox
, for displaying simple messages and warningsfiledialog
, for prompting the user for a file or folder pathsimpledialog
, for requesting string, integer, or float values from a user
In this section, we're going to explore these dialogs and use them to solve some of the problems with our application.
Error dialogs with the Tkinter messagebox
The best way to display simple dialog boxes in Tkinter is by using the tkinter.messagebox
module, which provides a variety of information-display dialog types.
Since it is a submodule, we need to explicitly import it before we can use it, like so:
from tkinter import messagebox
Rather than having a lot of widget classes that we create instances of, the messagebox
module provides a selection of convenience functions for making use of...