Learn to create desktop apps with Python and Qt. Screenshots on Ubuntu below. You can also use Windows or macOS.
![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|
Hello World! | Common PyQt Widgets | Layouts | Signals and Slots | Qt Designer & Python |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|
QML Python example | Qt Text Editor | Packaging & deployment | Qt Dark Theme |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|
Action Shooter | Chat Client | Tree Views | Lists |
![]() |
![]() |
---|---|
Custom Tables | PyQt database example |
Running the examples is really easy. The only thing you need is Python 3.
First, download the ZIP archive of this repository and unpack it. Open a command prompt and use cd
to navigate into the top-level directory of the archive.
Create a virtual environment via the command:
python3 -m venv venv
This creates the folder venv/
in your current directory. It will contain the necessary libraries for running the examples.
To activate the virtual environment, use the following command:
# On Windows:
call venv\Scripts\actviate.bat
# On Mac / Linux:
source venv/bin/activate
Now execute the following to install the necessary dependencies:
pip install -Ur src/requirements.txt
Once you have done this, use cd
to navigate to the example you're interested in in the src/
folder. For example:
cd "src/01 PyQt QLabel"
You'll find a .py
file there, typically main.py
. You can run it with the command:
python main.py
Please note that the virtual environment must still be active for this to work.
This repository uses PyQt5 to use Qt from Python. Another, alternative binding is PySide2 (also called "Qt for Python"). It is less mature than PyQt5 but has the advantage that you can use it for free in commercial projects.
If you want to use PySide2 instead of PyQt5, simply replace all mentions of the latter by the former. For instance, in src/requirements.txt
, replace PyQt5
by PySide2
. Similarly for any code examples: from PyQt5.QtWidgets ...
becomes from PySide2.QtWidgets ...
etc.
Except where otherwise indicated, the contents here are © me, Michael Herrmann. I'm happy for you to use the source code under the terms of the MIT license. The screenshots may be used under the terms of the CC BY-NC-SA 4.0.