[Tutor] Interesting book: "Python GUI Programming with Tkinter"

boB Stepp robertvstepp at gmail.com
Sat Sep 21 00:34:45 EDT 2019


I have been enjoying working with the book "Python GUI Programming
with Tkinter -- Develop responsive and powerful GUI applications with
Tkinter" by Alan D. Moore, c. 2018, published by Packt.

At the time of the book's writing Python 3.6.4 was current, though the
author frequently mentions the imminent arrival of Python 3.7 by
publishing time.  The book uses Tcl/Tk 8.6 though the author takes
pain to mention when something is 8.6 specific.  It emphasizes the use
of the ttk widgets, which typically give a more modern look and feel
than the tk widgets.  It does not cover tix widgets at all other than
mentioning they should be considered deprecated in terms of providing
a modern look and feel.

I like the approach the author is taking.  He states you are a
programmer for the fictional company ABQ AgriLabs.  You are assigned
the project of developing a simple data entry form which stores the
data as a CSV file.  The idea is to make data entry for the lab
technicians easier, quicker and error resistant.  Starting from this
beginning you are introduced to most of the functionality of tkinter.
The book assumes a basic grasp of Python 3 from the reader, including
the ability to write custom classes.  As your simple data entry form
gets used and receives user feedback from the fictional lab techs,
your program grows in scope.  The author addresses how to handle this
growth intelligently and speaks to good design and programming
practices.  By the end of the book your program has a PostgreSQL
backend, connects to the cloud, uses asynchronous program where
appropriate, uses both unit and integration testing and is packaged
for either PyPI or distributed as an executable for Windows, Mac or
Linux.

The author sometimes is brief, but other than basic Python knowledge
seems to assume nothing else on the part of the reader.  So, for
instance, he gives a crash course in SQL and relational databases
before getting into developing the database backend for PostgreSQL.
I'm several chapters into the book and feel I have learned a lot.

A coarse table of contents:

Preface
Ch. 1:  Introduction to Tkinter
    Introducing Tkinter and Tk
    Introducing IDLE  # Uses as an example of what can be done with tkinter.
    Creating a Tkinter Hello World

Ch. 2:  Designing GUI Applications with Tkinter
    A problem at ABQ AgriLabs
    Documenting specification requirements
    Designing the application

Ch. 3:  Creating Basic Forms with Tkinter and ttk Widgets
    Evaluating our technology choices
    Exploring Tkinter widgets
    Implementing the application

Ch. 4:  Reducing User Error with Validation and Automation
    Validating user input
    Validation in Tkinter
    Implementing validated widgets in our form
    Automating input

Ch. 5:  Planning for the Expansion of Our Application
    Separating concerns
        The MVC pattern
    Structuring our application directory
    Splitting our application into multiple  files
    Using version control software  # Gives a quick intro to Git

Ch. 6:  Creating Menus with Menu and Tkinter Dialogs
    Solving problems in our application
    Implementing simple Tkinter dialogs
    Designing our menu
    Making our settings work
        Persisting settings  # Introduces json for this purpose

Ch. 7:  Navigating Records with Treeview
    Implementing read and update in the model
    Implementing a record list view
    Modifying the record form for read and update
    Updating the rest of the application

Ch. 8:  Improving the Look with Styles and Themes
    Working with images in Tkinter
    Styling Tkinter widgets
    Styling Ttk widgets

Ch. 9:  Maintaining Cross-Platform Compatibility
    Writing cross-platform Python
        Filenames and filepaths across platforms
        Inconsistent library and feature support
        The dangers of the subprocess module
        Text file encodings and formats
        Graphical and console modes
        Writing code that changes according to the platform
    Writing cross-platform Tkinter
        Tkinter version differences across platforms
        Application menus across platforms
        Accelerator keys
        Fonts
        Theme support
        Window zoomed state
    Improving our application's cross-platform compatibility
        Storing preferences correctly
        Specifying an encoding for our CSV file
        Making platform-appropriate menus

Ch. 10:  Creating Automated Tests with unittest
    Automated testing basics
    Testing Tkinter code
        Managing asynchronous code
        Simulating user actions
        Managing focus and grab
        Getting widget information
    Writing tests for our application

Ch. 11:  Improving Data Storage with SQL
    PostgreSQL
    SQL and relational database basics
    Modeling relational data
    Creating the ABQ database
    Integrating SQL into our application

Ch. 12:  Connecting to the Cloud
    HTTP using urllib
    HTTP using requests
    FTP using ftplib

Ch. 13:  Asynchronous Programming with Thread and Queue
    Tkinter's event queue
    Running code in the background with threading
    Passing messages using a queue

Ch. 14:  Visualizing Data Using the Canvas Widget
    Drawing and animation with Tkinter's Canvas
    Creating simple graphs on the canvas
    Advanced graphs using Matplotlib and Tkinter

Ch. 15:  Packaging with setuptools and cx_Freeze
    Using setuptools
    Using cx_Freeze
    Building Windows executables with cx_Freeze
    Building macOS executables with cx_Freeze

--
boB


-- 
boB


More information about the Tutor mailing list