PPG
PPG copied to clipboard
Create Powerful Python Apps with Qt5/Qt6
PPG - Python Package Generator
Sleek, intuitive, and powerful tool for faster and easier PyQt/PySide App development.
Explore PPG docs »
Table of contents
- Quick start
- Status
- What's Changed
- Getting started
- CLI Usage
- The Life Cycle of a component
- Creators
- Copyright and license
Quick start
Several quick start options are available:
- Download the latest release
- Clone the repo:
git clone https://github.com/runesc/ppg.git
- Install with Pip:
pip install ppg
Read the Getting started section for information, templates, examples, and more.
Status

What's Changed
- Fixed
build_settings
inApplicationContext
✅ - Fixed
ppg freeze
✅ - Fixed
shiboken6
hook ✅ - Modified
project_template
inppg/builtin_commands/project_template
✅ - Modified LifeCycle class, new methods were added like:
-
component_will_mount
Renamed -
allow_bg
New -
render_
-
resizeEvent
Updated -
component_did_mount
Renamed -
set_CSS
Renamed -
responsive_UI
Renamed -
destroyComponent
New -
find
New -
calc
New For more info check the docs. ✅
-
-
New! Now you can create components or views just typing
ppg create component
🎉 - Fixed component template does not import selected widget ✅
- Modified Icons updated
Getting started
This section is a step-by-step overview of using the PPG tool for creating apps.
Overview
- Setup
- Create a project
- Running the app
- Compile your app
Setup
There are different ways to install PPG but before installing it, we recommend creating a virtual environment with virtualenv or conda. We do not recommend installing it directly on your computer to avoid compatibility problems in future projects.
Using Conda
Run the following command to create your virtual environment:
conda create -n YOUR_ENV_NAME python=3.X -y
Activate your virtual enviroment.
conda activate YOUR_ENV_NAME
Using Virtualenv
python -m venv venv
Activate your virtual enviroment.
# On Mac/Linux:
source venv/bin/activate
# On Windows:
call venv\scripts\activate.bat
Installing PPG
Now we need to install PPG.
# Using Pypi
pip install ppg
# Using github repository
pip install https://github.com/runesc/PPG.git
# From source code
curl -L -O https://github.com/runesc/PPG.git
unzip PPG.zip
cd PPG/
python setup.py install
Great! You already have PPG installed, now you need to choose the Qt binding that you prefer in our case we will use PySide6.
Create a project
Creating a project is the easiest part of PPG, you just have to answer a few questions and that's it.
# Just write
ppg init
# Console displays:
PPG init v1.0.0
App name [MyApp] : MyDemoApp
Version [1.0.0] : 1.0.0
Author [ppg] : you
Please select your Qt binding [default: 'PySide6']: 1) PyQt5 or 2) PyQt6 or 3) PySide2 or 4) PySide6 [4] : 4
Mac bundle identifier (eg. com.you.mydemoapp, optional):
Created the src/ directory. If you have PySide6 installed, you can now
do:
ppg run
Running the app
As you can see, two folders src/
and requirements/
have been created later on we will see in detail what those folders do for now, focus on executing the application
# Just write
ppg run
It's like magic!🎉🌌 You already have a template where you can start expressing your ideas with code.
Compile your app
We want to turn the source code of our app into a standalone executable that can be run on your users' computers. In the context of Python applications, this process is called "freezing".
Use the following command to turn the app's source code into a standalone executable:
# Just write
ppg freeze
This creates the folder target/YourApp/
. You can copy this directory to any other computer (with the same OS as yours) and run the app there.
Now we have generated a binary that can run on any PC as long as they use the same operating system (if you compile on Windows you can't run the app on Linux or MacOS) but we need an elegant way to distribute our apps because we can't send the app in zip and ask the user to unzip it and run for that we can choose an installer (setup.exe
on Windows, .dmg
on MacOS or .deb/.rpm/.pkg.tar.xz
on Linux.
To be able to generate an installer you just have to write the following command:
# Create a installer
ppg installer
Using the CLI
PPG CLI is a command line interface tool used to initialize, develop, structure, and maintain Qt applications directly from a command shell.
Overview
- ppg init
- ppg start
- ppg create
- ppg freeze
- ppg installer
- ppg sign
- ppg sign_installer
- ppg test
- ppg clean
ppg init
Create an Python/Qt workspace.
ppg init
Description
Create and initialize a new Python/Qt application that is the default project for a new workspace.
Provides interactive prompts for initial configuration, such as binding to use, version, app name and more. All prompts can be allowed to be safely set by default.
The new workspace folder is named src/
specified and contains configuration files.
By default, the files for a new starter application are placed in the src/
folder.
The configuration of the new application appears in the section of build/settings
where the configuration file of the workspace base.json
is located
ppg start
Builds and serves your app.
ppg start
ppg create
Create a new component or view.
ppg create <element>
Description
Add a new component to the workspace and configure the project to use it, it can be an empty widget (QWidget
) or a simple component like a QPushButton
.
The CLI provides a simple interface where you can select the type of widget you want to work with and the type of component that will be created (view
or component
) and it is saved in its respective folder (components/
/ or views/
/).
Arguments
Argument | Description | Value type |
---|---|---|
<component> |
Select the type of component to be used (view or component). | string |
ppg freeze
Compile the source code and transform it into an executable file
ppg freeze [options]
Description
Creates an executable file that can be used on any PC that uses the same operating system for which it was compiled.
Options
Argument | Description | Value type | Default value |
---|---|---|---|
--debug |
It shows a log in the compilation and when executing the app it shows the status in a terminal. | boolean |
false |
ppg installer
Create a user-friendly installer that can be distributed in a classic way.
ppg installer
ppg sign
Signs the executable file with a .pfx
certificate so that it cannot be detected by antivirus as malware. (the signed certificate must be placed in src/sign/windows/certificate.pfx
)
ppg sign
ppg sign_installer
Signs the installer file with a .pfx
certificate so that it cannot be detected by antivirus as malware. (the signed certificate must be placed in src/sign/windows/certificate.pfx
)
ppg sign_installer
ppg test
Automatically run the unit tests you put in src/unittest/python
ppg test
ppg clean
Clean up the waste and configuration files that are generated when compiling an application.
ppg clean
The Life Cycle of a component
Before starting to design applications with ppg it is very important to understand the life cycle of a component.
The life cycle is a fundamental part in app development since it allows to have a better control and code structure when implementing an app, it is found in each component generated by the CLI and in the main class of each project. We recommend including it in your custom components for better integration.
Creators
Luis Alfredo Reyes
Copyright and license
Code and documentation copyright 2020–2021 the PPG Code released under the GPL v3 License. Docs released under Creative Commons.