Search icon
Subscription
0
Cart icon
Close icon
You have no products in your basket yet
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Python GUI Programming with Tkinter, 2nd edition - Second Edition

You're reading from  Python GUI Programming with Tkinter, 2nd edition - Second Edition

Product type Book
Published in Oct 2021
Publisher Packt
ISBN-13 9781801815925
Pages 664 pages
Edition 2nd Edition
Languages
Author (1):
Alan D. Moore Alan D. Moore
Profile icon Alan D. Moore

Table of Contents (22) Chapters

Preface 1. Introduction to Tkinter 2. Designing GUI Applications 3. Creating Basic Forms with Tkinter and Ttk Widgets 4. Organizing Our Code with Classes 5. Reducing User Error with Validation and Automation 6. Planning for the Expansion of Our Application 7. Creating Menus with Menu and Tkinter Dialogs 8. Navigating Records with Treeview and Notebook 9. Improving the Look with Styles and Themes 10. Maintaining Cross-Platform Compatibility 11. Creating Automated Tests with unittest 12. Improving Data Storage with SQL 13. Connecting to the Cloud 14. Asynchronous Programming with Thread and Queue 15. Visualizing Data Using the Canvas Widget 16. Packaging with setuptools and cxFreeze 17. A: A Quick Primer on reStructuredText 18. B: A Quick SQL Tutorial 19. Other Books You May Enjoy
20. Index
Appendices

To get the most out of this book

This book expects that you know the basics of Python 3. You should know how to write and run simple scripts using built-in types and functions, how to define your own functions, and how to import modules from the standard library.

You can follow this book on a computer running a current version of Microsoft Windows, Apple macOS, or a distribution of GNU/Linux. Ensure that you have Python 3 and Tcl/Tk installed (Chapter 1, Introduction to Tkinter, contains instructions for Windows, macOS, and Linux) and that you have a code editing environment with which you are comfortable (we suggest IDLE since it comes with Python and uses Tkinter. We do not recommend the use of Jupyter, Spyder, or similar environments aimed at analytical Python rather than application development). In the later chapters, you'll need access to the internet so that you can install Python packages and the PostgreSQL database.

Download the example code files

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Python-GUI-Programming-with-Tkinter-2E. We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images

We also provide a PDF file that has color images of the screenshots/diagrams used in this book. You can download it here: https://static.packt-cdn.com/downloads/9781801815925_ColorImages.pdf.

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. For example: "Save the code in solve_the_worlds_problems.py and execute it by typing python solve_the_worlds_problems.py at a terminal prompt."

A block of code is set as follows:

import tkinter as tk
root = tk.TK()
def solve():
  raise NotImplemented("Sorry!")
tk.Button(
  root, text="Solve the world's problems", command=solve
).pack()
root.mainloop()

When we wish to draw your attention to a particular part of a code block, especially to indicate changes to existing code, the relevant lines or items are set in bold:

import tkinter as tk
from tkinter import messagebox
root = tk.TK()
def solve():
  messagebox.showinfo('The answer?', 'Bananas?')
tk.Button(
  root, text="Solve the world's problems", command=solve
).pack()
root.mainloop()

Note that all Python code in the book uses 2-space indents rather than the conventional 4-space indents.

Any command-line input or output is written with a $ indicating the prompt, as follows:

$ mkdir Bananas
$ cp plantains.txt Bananas/

Command line input intended for the Python shell or REPL is printed with a prompt of >>>, like so:

>>> print('This should be run in a Python shell')
'This should be run in a Python shell'

Expected output from the shell is printed on a line with no prompt.

Bold: Indicates a new term, an important word, or words that you see on the screen, for example, in menus or dialog boxes. For example: "Select System info from the Administration panel."

Warnings or important notes appear like this.

Tips and tricks appear like this.

Executing Python and pip

When we need to instruct the reader to execute a Python script in this book, we indicate a command line such as the following:

$ python myscript.py

Depending on your operating system or Python configuration, the python command may execute Python 2.x rather than Python 3.x. You can verify this by running the following command:

$ python --version
Python 3.9.7

If this command outputs Python 2 rather than 3 on your system, you will need to alter any python commands so that your code is executed in Python 3. Typically, that means using the python3 command instead, like so:

$ python3 myscript.py

The same caveat applies to the pip command used to install libraries from the Python Package Index. You may need to use the pip3 command instead to install libraries to your Python 3 environment, for example:

$ pip3 install --user requests
lock icon The rest of the chapter is locked
Next Chapter arrow right
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at AU $19.99/month. Cancel anytime}