Create GUI Applications with PySide2

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

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.

PySide, also known as Qt for Python, is a Python GUI framework for creating GUI applications using the Qt toolkit. PySide is the official binding for Qt on Python and is now developed by The Qt Company itself.

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.

PySide2 not installed? See our installation guides for Windows, macOS and Linux

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

The QResource System

Using the QResource system to package additional data with your applications

Creating Dialogs With Qt Designer

Using the drag and drop editor to build PySide2 dialogs

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 PySide2 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

Latest Data Science tutorials

Displaying tabular data in Qt ModelViews

Create customized table views with conditional formatting, numpy and pandas data sources.

Plotting with PyQtGraph

Create custom plots in PySide with PyQtGraph

Plotting with Matplotlib

Create PySide plots with the popular Python plotting library

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 PySide2 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

QPainter and Bitmap Graphics

Introduction to the core features of QPainter

Creating custom GUI widgets in PySide2

Build a completely functional custom widget from scratch using 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

Latest Packaging & Distribution tutorials

PySide2 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

QPushButton

Add clickable buttons to your Python UI

Getting started with VS Code for Python

Setting up a Development Environment for Python programming

Which Python GUI library should you use?

Comparing the Python GUI libraries available in 2022

Understanding the GPL and "Copyleft"

When Are Two Open Source Software Licenses Incompatible?

The Basics of Software Copyrights

Why Do You Need to Bother With Licensing at All?

More articles