Book Image

Python GUI Programming with Tkinter.

By : Alan D. Moore
Book Image

Python GUI Programming with Tkinter.

By: Alan D. Moore

Overview of this book

Tkinter is a lightweight, portable, and easy-to-use graphical toolkit available in the Python Standard Library, widely used to build Python GUIs due to its simplicity and availability. This book teaches you to design and build graphical user interfaces that are functional, appealing, and user-friendly using the powerful combination of Python and Tkinter. After being introduced to Tkinter, you will be guided step-by-step through the application development process. Over the course of the book, your application will evolve from a simple data-entry form to a complex data management and visualization tool while maintaining a clean and robust design. In addition to building the GUI, you'll learn how to connect to external databases and network resources, test your code to avoid errors, and maximize performance using asynchronous programming. You'll make the most of Tkinter's cross-platform availability by learning how to maintain compatibility, mimic platform-native look and feel, and build executables for deployment across popular computing platforms. By the end of this book, you will have the skills and confidence to design and build powerful high-end GUI applications to solve real-world problems.
Table of Contents (23 chapters)
Title Page
Copyright and Credits
Packt Upsell

Modifying the record form for read and update

As long as we're editing views, we'll need to look at our DataRecordForm view and adjust it to make it capable of updating records.

Take a moment and consider the following changes we'll need to make:

  • The form will need some way to load in a record provided by the controller.
  • The form will need to keep track of what record it's editing, or if it's a new record.
  • Our user will need some visual indication of what record is being edited.
  • Our Save button is currently in the application. It doesn't really make sense in any context other than the form, so it should probably be part of the form.
  • This means our form will need a callback to call when the save button is clicked. We'll need to provide it with a callbacks dictionary like we did with our other views.

Updating __init__()

Let's start working through these with our __init__() method:

    def __init__(self, parent, fields, 
                 settings, callbacks, *args, **kwargs):