Skip to Content
Python GUI Programming with Tkinter
book

Python GUI Programming with Tkinter

by Alan D. Moore
May 2018
Beginner to intermediate content levelBeginner to intermediate
452 pages
11h 26m
English
Packt Publishing
Content preview from Python GUI Programming with Tkinter

Showing the error dialogs

Now that you understand how to use messagebox, error dialogs should be easy to implement. The Application.on_save() method already displays errors in the status bar; we just need to make this error display in an error message box as well by performing the following steps:

  1. First, we'll need to import it in application.py as follows:
from tkinter import messagebox
  1. Now, in the on_save() method after the check for errors, we'll set up the message for the error dialog. We'll make a bullet list of the fields with errors by joining them with "\n *". Unfortunately, messagebox doesn't support any sort of markup, so constructs like bullet lists need to be built manually using regular characters, as in the following:
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Python GUI Programming with Tkinter - Second Edition

Python GUI Programming with Tkinter - Second Edition

Alan D. Moore

Publisher Resources

ISBN: 9781788835886Supplemental Content