Book Image

Python GUI Programming - A Complete Reference Guide

By : Alan D. Moore, B. M. Harwani
Book Image

Python GUI Programming - A Complete Reference Guide

By: Alan D. Moore, B. M. Harwani

Overview of this book

A responsive graphical user interface (GUI) helps you interact with your application, improves user experience, and enhances the efficiency of your applications. With Python, you’ll have access to elaborate GUI frameworks that you can use to build interactive GUIs that stand apart from the rest. This Learning Path begins by introducing you to Tkinter and PyQt, before guiding you through the application development process. As you expand your GUI by adding more widgets, you'll work with networks, databases, and graphical libraries that enhance its functionality. You'll also learn how to connect to external databases and network resources, test your code, and maximize performance using asynchronous programming. In later chapters, you'll understand how to use the cross-platform features of Tkinter and Qt5 to maintain compatibility across platforms. You’ll be able to mimic the platform-native look and feel, and build executables for deployment across popular computing platforms. By the end of this Learning Path, you'll have the skills and confidence to design and build high-end GUI applications that can solve real-world problems. This Learning Path includes content from the following Packt products: Python GUI Programming with Tkinter by Alan D. Moore Qt5 Python GUI Programming Cookbook by B. M. Harwani
Table of Contents (28 chapters)
Title Page

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 classes, and how to import modules from the standard library.

You can follow this book if you run Windows, macOS, Linux, or even BSD. Ensure that you have Python 3 and Tcl/Tk installed and that you have an editing environment with which you are comfortable (we suggest IDLE since it comes with Python and uses Tkinter). In the later chapters, you'll need access to the internet so that you can install Python packages and the PostgreSQL database.

To run Python scripts on Android devices, you need to install QPython on your Android device. To package Python scripts into Android’s APK using the Kivy library, you need to install Kivy, a Virtual Box, and Buildozer packager. Similarly, to run Python scripts on iOS devices, you need a macOS machine and some library tools, including Cython.

Download the Example Code Files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at https://github.com/PacktPublishing/Python-GUI-Programming-A-Complete-Reference-Guide. In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalog of books and videos available at https://github.com/PacktPublishing/. Check them out!

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. Here is an example: "Determine the appropriate input widget for each data field."

A block of code is set as follows:

def has_five_or_less_chars(string):
return len(string) <= 5

wrapped_function = root.register(has_five_or_less_chars)
vcmd = (wrapped_function, '%P')
five_char_input = ttk.Entry(root, validate='key', validatecommand=vcmd)

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

[default]
exten => s,1,Dial(Zap/1|30)
exten => s,2,Voicemail(u100)
exten => s,102,Voicemail(b100)
exten => i,1,Voicemail(s0)

Any command-line input or output is written as follows:

pip install --user psycopg2-binary

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "Once installed, launch pgAdmin and create a new admin user for yourself by selecting Object Create | Login/Group Role."

Warnings or important notes appear like this.
Tips and tricks appear like this.