Book Image

Mastering GUI Programming with Python

By : Alan D. Moore
5 (2)
Book Image

Mastering GUI Programming with Python

5 (2)
By: Alan D. Moore

Overview of this book

PyQt5 has long been the most powerful and comprehensive GUI framework available for Python, yet there is a lack of cohesive resources available for Python programmers to learn how to use it. This book will be your comprehensive guide to exploring GUI development with PyQt5. You will get started with an introduction to PyQt5, before going on to develop stunning GUIs with modern features. You will learn how to build forms using QWidgets and delve into important aspects of GUI development such as layouts, size policies, and event-driven programming. Moving ahead, you’ll discover PyQt5’s most powerful features through chapters on audio-visual programming with QtMultimedia, database-driven software with QtSQL, and web browsing with QtWebEngine. Next, in-depth coverage of multithreading and asynchronous programming will help you run tasks asynchronously and build high-concurrency processes with ease. In later chapters, you’ll gain insights into QOpenGLWidget, along with mastering techniques for creating 2D graphics with QPainter. You’ll also explore PyQt on a Raspberry Pi and interface it with remote systems using QtNetwork. Finally, you will learn how to distribute your applications using setuptools and PyInstaller. By the end of this book, you will have the skills you need to develop robust GUI applications using PyQt.
Table of Contents (24 chapters)
Free Chapter
1
Section 1: Deep Dive into PyQt
8
Section 2: Working with External Resources
12
Section 3: Unraveling Advanced Qt Implementations
22
Upgrading Raspbian 9 to Raspbian 10

To get the most out of this book

The reader is expected to have proficiency in the Python language, particularly Python 3. You should understand, at least in a basic sense, how to work with classes and object-oriented programming. You may find it helpful to have a passing familiarity with C++, since most of the available Qt documentation is aimed at that language.

You should have a computer running Windows, macOS, or Linux on which Python 3.7 has been installed, and on which you can install other software as needed. You should have a code editor and command-line shell with which you are comfortable. Finally, you should have access to the internet.

Each chapter of this book contains one or more example applications. Although these examples are available for download, you are encouraged to follow along, creating these applications by hand to see the intermediate stages as the applications come together.

Each chapter also contains a series of questions or a suggested project to cement your knowledge of the topic, and a selection of resources for further study on the topic. You will get the most out of each chapter if you engage your mind and creativity in solving these problems and reading the provided materials.

The code included in this book is released under the open source MIT license, which allows you to re-use the code as you see fit, provided you retain the included copyright notices. You are encouraged to use, modify, improve, and re-publish these programs.

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/Mastering-GUI-Programming-with-Python/tree/master. 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!

Download the color images

Code in action

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: "HTML documents are built hierarchically, with the outermost tag usually being <html>."

A block of code is set as follows:

<table border=2>
<thead>
<tr bgcolor='grey'><th>System</th><th>Graphics</th><th>Sound</th></tr>
</thead>

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

<table border=2>
<thead>
<tr bgcolor='grey'><th>System</th><th>Graphics</th><th>Sound</th></tr>
</thead>

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

$ python game_lobby.py
Font is Totally Nonexistent Font Family XYZ
Actual font used is Bitstream Vera Sans

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: "Select System info from the Administration panel."

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