Create GUI Applications with PyQt5

Want to create Python GUIs? Here is everything you need to go from simple UIs to complete apps with PyQt5.

Building GUI applications with Python doesn't have to be difficult. In this tutorial I'll walk you step by step from simple Python GUIs to real useful apps.

By the end of the tutorial you'll be able to make your own applications, design professional UIs and even create installers and packages to share your apps with other people.

PyQt5 is a Python GUI framework for making GUI applications using the Qt toolkit. Created by Riverbank Computing, the PyQt library is free software (GPL licensed) and has been in development since 1999. PyQt5 was released in 2016 and last updated in October 2021.

This tutorial requires some basic Python knowledge, but no experience with GUI programming.

Take your first steps creating Python GUI applications with these simple step-by-step guides to Python & Qt.

PyQt5 not installed? See our installation guides for Windows, macOS, Linux and Raspberry Pi

Once you're set up you can get started by Creating your first GUI application with Python.

Now you have made your first GUI app, let's go a step further adding widgets and layouts to build some simple Python UIs.

So far we have been creating apps using Python code. This works well in many cases, but it can get a bit cumbersome to define all widgets programmatically. The good news is that Qt comes with a graphical editorQt Designer — which contains a drag-and-drop UI editor. Using Qt Designer you can define your UIs visually and then simply hook up the application logic later.

If you're going to be distributing your applications, you might also want to take a look at the QResource framework which simplifies bundling data files (like icons) with your applications.

Explore Qt Designer

Latest Qt Designer tutorials

Install Qt Designer Standalone

Qt Designer Download for Windows, Mac and Linux

The QResource System

Using the QResource system to package additional data with your applications

Most Python apps need to interact with data sources — whether that's a CSV file, database or remote APIs. One of the main benefits of using Python to build applications is being able to make use of Python's data science tools to process and analyse data.

With PyQt5 you can make use of Qt's model view architecture to display performant views of any Python data in your applications. Or embed matplotlib and PyQtGraph plots for dynamic visualizations.

If you're using Qt Designer to create your applications, take a look at how to use PyQtGraph & Matplotlib widgets inside Qt Designer.

Explore Data Science

Building real applications, you'll find yourself wanting to perform long-running tasks. For example, your application might need to interact with remote APIs or perform complex calculations.

But you'll notice a problem: while the long-running task completes, your app will become unresponsive. Your code blocks Qt from running until it returns.

In these tutorials we'll discover how to use threads & processes to long-running tasks while keeping your app responsive.

Explore Concurrency

Qt comes with a large library of widgets built-in. But sometimes your applications need something different. In PyQt5 you can you design your own widgets, drawing them directly in your application.

In these tutorials we'll go through the basics of drawing graphics in Qt to building your own entirely custom widget.

Explore Custom Widgets

Latest Custom Widgets tutorials

Animating custom widgets with QPropertyAnimation

Add dynamic visual effects to your custom widgets

Creating custom GUI widgets in PyQt5

Build a completely functional custom widget from scratch using QPainter

QPainter and Bitmap Graphics

Introduction to the core features of QPainter

There comes a point in any app's development where it needs to leave home — half the fun in writing software is being able to share it with other people. Packaging Python GUI apps can be a little tricky, but these guides will walk you through the process step by step.

If you're using Qt Designer you may want to take a look at the QResource system and how you can use it to package data files with your apps.

Explore Packaging & Distribution

PyQt5 has two APIs for building GUIs. We've already introduced the Qt Widgets API which is well-suited for building desktop applications. Qt also provides a declarative API in the form of Qt Quick/QML. Qt Quick is well suited for building modern touchscreen interfaces for microcontrollers or device interfaces.

Explore QML/QtQuick

Books

Hands-on guides to Python GUI programming

Books taking you from first principles to fully-functional apps, not toy examples.

See all Python GUIs books

Latest Updates

PyQt6 & PySide6 Books updated for 2024

Extended and updated with new examples, demos including Model View Controller architecture

Working With Python Virtual Environments

Setting Your Python Working Environment, the Right Way

Which Python GUI library should you use?

Comparing the Python GUI libraries available in 2024

QLineEdit

A Simple Text Input Widget

Plotting With PyQtGraph

Create Custom Plots in PyQt with PyQtGraph

How Trademarks Affect Open Source Software

How do trademarks relate to copyrights and what are the implications for open source software

More articles