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

Implementing a record list view

The record list view will allow our users to browse the content of the file and open records for viewing or editing. Our users are accustomed to seeing this data in a spreadsheet, laid out in a table-like format, so it makes sense to design our view in a similar fashion. Since our view mainly exists for finding and selecting individual records, we don't need to display all the information; just enough for the users to distinguish one record from another.

A quick analysis shows that we need CSV row number, Date, Time, Lab, and Plot.

For building table-like views with selectable rows, Tkinter gives us the ttk  Treeview widget. To build our record list view, we'll need to learn about Treeview.

The ttk Treeview

The Treeview is a ttk widget designed to show columns of data in a hierarchical structure.

Perhaps the best example of this kind of data is a filesystem tree:

  • Each row can represent a file or directory
  • Each directory can contain additional files or directories...