File: README.md
Python GUIs Examples
This repository contains 100s of GUI examples written in Python. From complete working applications to reusable widgets snippets, these examples can
be freely re-used, re-mixed and tweaked to build your own Python GUI applications.
Contributions Welcome
This repo is an open collaborative collection of UI demonstrations, tutorials and examples for Python. New additions are welcome, just fork this repository, add your example code file(s) in the [library]/[type]/[folder-name] and open a pull request.
Browse this repo
Examples are available for
PyQt6 and
PySide6,
(many examples) along with
DearPyGui,
Flet,
Kivy,
NiceGUI,
PyQt5
PySide2
Streamlit and
Tkinter
Not sure which library to use? See our Which Python GUI? guide.
Many of these examples have more detailed write-ups on the Python GUIs website. See the source code for example to get links to the specific tutorials.
If you're new to creating GUI apps check out the introductory PyQt6 tutorial or PySide6 tutorial.
Demo Showcase
Some particularly neat examples of UIs build using Python are linked below. The full source code for these examples is available in this repo. In some cases there are also step by step examples of the app being built.
- Web Browser (untabbed) - "MooseAche" PyQt6 PySide6
- Web Browser (tabbed) - "Mozzarella Ashbadger" PyQt6 PySide6
- Minesweeper - "Moonsweeper" PyQt6 PySide6
- Notepad - "No2Pads" PyQt6 PySide6
- Calculator - "Calculon" (QtDesigner) PyQt6 PySide6
- Word Processor - "Megasolid Idiom" PyQt6 PySide6
- Webcam/Snapshot - "NSAViewer" PyQt6 PySide6
- Media Player - "Failamp" PyQt6 PySide6
- Post-it Notes - "Brown Note" (QtDesigner) PyQt6 PySide6
- Paint - "Piecasso" (QtDesigner) PyQt6 PySide6
- Unzip - "7Pez" (QtDesigner) PyQt6 PySide6
- Translator - "Translataarrr" (QtDesigner) PyQt6 PySide6
- Weather - "Raindar" (QtDesigner) PyQt6 PySide6
- Currency converter - "Doughnut" (PyQtGraph) PyQt6 PySide6
- Solitaire - "Ronery" (QGraphicsScene) PyQt6 PySide6
This is just a selection of the demos in this repo, pick a library and look under the demos/ folder.
Tutorials
Alongside the demos we also have step by step tutorial code, taken from our main site at pythonguis.com. These guide you through building GUIs with PyQt, PySide and other libraries. For example example there is a link back to the tutorial (and vice versa).
Getting started
To use each app you first need to install the requirements. In most cases
the only requirements are the GUI library and occasionally requests. To install
example specific requirements change to the folder of the example and run:
pip3 install -r requirements.txtOnce the requirements are installed, you can run the app. Every example in this repo comes with a main Python file called main.py to keep things simple.
python3 main.pyThe application window should appear.
Want to build your own apps?
If you think these apps are neat and want to learn more about
take a look at my PyQt6 tutorial
which covers everything you need to know to start building your own applications with Python.
You can also find more write-ups and tips on the same site.
Books & Courses
This repository and the Python GUIs website are both projects of Martin Fitzpatrick -- hello! I've written a number of popular books & courses on Python GUI programming, which you can find here https://www.pythonguis.com/books
Need help with your Python GUI project? I'm available to hire
Licenses
All code is licensed under an MIT license. This allows you to re-use the code freely, remixed in both commercial and non-commercial projects. The only requirement is to include the same license when distributing.
Icons used in the applications are by Yusuke Kamiyaman.
File: pyqt5/tutorials/layouts/README.md
PyQt5 Layouts
This folder contains the code examples for the PythonGUIs tutorial PyQt5 Layouts.
File: pyqt5/tutorials/dialogs/README.md
PyQt5 Dialogs and Alerts
This folder contains the code examples for the PythonGUIs tutorial PyQt5 Dialogs and Alerts.
File: pyqt5/tutorials/creating-your-first-window/README.md
Creating your first app with PyQt5
This folder contains the code examples for the PythonGUIs tutorial Creating your first app with PyQt5.
File: pyqt5/tutorials/basic-widgets/README.md
PyQt5 Widgets
This folder contains the code examples for the PythonGUIs tutorial PyQt5 Widgets.
File: pyqt5/demos/wordprocessor/README.md
Megasolid Idiom βΒ A rich text editor in PyQt
The word processor for all your small, poorly formatted documents.
An extension of the notepad, again using a QTextEdit but with rich
text editing enabled.
The editor supports multiple fonts, styles and paragraph text alignment.
There is also support for drag-drop of images, which are automatically
opened and embedded.
Saves and opens HTML format documents.
If you want to learn more about build GUI applications with Python,
take a look at my PyQt5 tutorials
which covers everything you need to know to start building your own applications with PyQt5.
Other licenses
Icons used in the application are by Yusuke Kamiyaman.
File: pyqt5/demos/weather/README.md
Raindar β A weather forecast app built in PyQt
Get your daily weather and 15hr forecast. Data is provided by the free
weather and forecast API from https://openweathermap.org/
If you want to learn more about build GUI applications with Python,
take a look at my PyQt5 tutorials
which covers everything you need to know to start building your own applications with PyQt5.
Other licenses
Icons used in the application are by Yusuke Kamiyaman.
They were renamed to match codes generated by OpenWeatherMap.
File: pyqt5/demos/unzip/README.md
7Pez βΒ the best/worst Unzip application ever created
Unzip your files with a cat. Drag-drop your zip file onto the floaty
cat, and fill up it's Pez-file repository. Press the head to release
the Pez (your files) into the same folder.
When you open the application the catty Pez dispenser is empty.
Simply drag and drop your .zip file onto the cat to fill it up with Pez.
The press the cat's head to release the Pez.
If you want to learn more about build GUI applications with Python,
take a look at my PyQt5 tutorials
which covers everything you need to know to start building your own applications with PyQt5.
Code notes
Pez
If you know anything about Pez you'll know this application has it the wrong
way around. That's because I remembered it wrong, thinking that you pressed
the head of a Pez dispenser to make it drop Pez out the bottom.
Originally the intention was to make you press the head once for every file
you wanted to release, but that was excruciating. It's bad enough as it is.
File: pyqt5/demos/translate/README.md
Translatarrrr β Instant translation from any language to Pirate
A translator from any language (supported by Google translate) to pirate.
This uses a remote API from http://api.funtranslations.com for English
to Pirate translation, and a unofficial Python wrapper around Google translate
for other languages to English.
The to English part uses a Python library built on the web interface,
rather than an official API client since it's a faff to set up + non-free.
This means this part of the application is not guaranteed to work.
The to Pirate part uses a public API that is heavily throttled. You'll
usually get about 5 translations before the limit kicks in. You can
pay for an API key to get more.
This is, therefore, very useless.
If you want to learn more about build GUI applications with Python,
take a look at my PyQt5 tutorials
which covers everything you need to know to start building your own applications with PyQt5.
File: pyqt5/demos/solitaire/README.md
Ronery βΒ A Solitaire game in PyQt
The classic card Solitaire (Klondike) game with a North Korean /
'Team America: World Police' twist. The game is otherwise identical,
offering the same options. Built with PyQt, it uses QGraphicsScene
to handle the play area.
The classic Solitaire win-screen is also implemented, although since
the play canvas is not a bitmap it doesn't "fill up". It's still
sufficiently satisfying.
The configuration options allow for 3-draw and 1 draw styles, with 3, 5
or infinite rounds.
Code notes
Card handling
The approach I used here was to treat each place where cards can be placed
as a 'stack' object, which handles the cards it currently holds. Each stack
is responsible for the layout of the cards on it's pile.
A stack is also responsibly for accepting/rejecting an attempted drop of a
card on it. Some stacks, e.g. the deck + deal pile do not accept any drop.
Others, such as the finish piles, have specific rules.
In most cases there is no relationship between any cards on a stack, with
the exception of the 'in play' stacks along the bottom. Here cards have
a parent-child relationship, allowing multiple cards to be dragged at once.
The end animation
The end-game was a bit weird to implement. Since it is self-contained
and happens 'outside' of game time the first thought was to have a
separate fake event loop, hitting QApplication.processEvents to
tick over. But that's nasty.
Instead the animation is handled by a QTimer, normally idle during play,
which once triggered repeatedly pings an
animation step-forward slot. This moves cards (faking 'gravity', bouncing)
as well as re-stacking them once they're out of the play area.
Restacking uses the normal stacking code so they can pile up.
The final piece of the puzzle was to block user interaction, otherwise
the cards could still be grabbed and dropped they bounced.
The easiest way to achieve this is to place an object over the entire
window which is set to capture (and discard) all mouse clicks.
Other licenses
The card images were made from a freely available set of PNGs
which were themselves auto-generated from SVGs traced from actual cards(!).
The original card designs are out of copyright.
Note that the linked repository contains some custom art on ace cards which may still be copyrighted and so
was not used.
Icons used in the application are by Yusuke Kamiyaman.
If you want to learn more about build GUI applications with Python,
take a look at my PyQt5 tutorials
which covers everything you need to know to start building your own applications with PyQt5.