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
Dedication
Packt Upsell
Contributors
Preface
Index

Implementing read and update in the model


Our entire design up to this point has been centered around a form that only appends data to a file; adding read and update capabilities is a fundamental change that will touch nearly every portion of the application. It may seem like a daunting task, but by taking it one component at a time, we'll see that the changes are not so overwhelming.

The first thing we should do is update our documentation, starting with the Requirements section:

The program must:

* Provide a UI for reading, updating, and appending data to the CSV file
* ...

And, of course, also update the part that is not required that follows:

The program does not need to:

* Allow deletion of data.

Now, it's a simple matter of making the code match with the documentation.

Adding read and update to our model

Open models.py and consider what's missing from the CSVModel class:

  • We'll need a method that can retrieve all records in a file so we can display them. We'll call it get_all_records().
  • We...