August 2018
Intermediate to advanced
366 pages
10h 14m
English
The alert function itself is just a thin wrapper over what tkinter.messagebox provides.
There are three types of message boxes we can show: error, warning, and info. If an unsupported kind of dialog box is requested, we just reject it:
if kind not in ('error', 'warning', 'info'):
raise ValueError('Unsupported alert kind.')
Each kind of dialog box is shown by relying on a different method of the messagebox. The information boxes are shown using messagebox.showinfo, while errors are shown using messagebox.showerror, and so on.
So, we grab the relevant method of messagebox:
show_method = getattr(messagebox, 'show{}'.format(kind))
Then, we call it to display our box:
show_method(title, message)
The alert function is very simple, ...