This is only for demonstrating and reference.
pdm run desktop-app
Install with pipx
pipx install git+https://github.com/mrjohannchang/minimum-qt-for-python-desktop-application-demo.git
pdm install
-
Create an empty project with Git.
git init -
Initialize the Python project with PDM.
pdm init -
Add Qt for Python as a dependent library.
pdm add PySide6 -
Create a Main Window Qt Designer UI file with Qt Designer.
mkdir src/minimum_qt_for_python_desktop_application_demo_desktop touch src/minimum_qt_for_python_desktop_application_demo_desktop/__init__.py mkdir src/minimum_qt_for_python_desktop_application_demo_desktop/ui touch src/minimum_qt_for_python_desktop_application_demo_desktop/ui/__init__.py pdm run pyside6-designer -
Create the desktop application entry point. If you chose PEP 582 – Python local packages directory for this project and plan to use PyCharm, at the time of writing, PyCharm does not support PEP 582 directly. Please manually set
__pypackages__/<major.minor>/libandsrcas Sources Root.-
After configuring the script file in
pyproject.toml, we need to install it:pdm install -
Then we will be able to run it:
pdm run desktop-app
-
-
Add the logging function to the custom SDK.
-
Use custom
QMainWindowclass to add the window exit hook.Note: This is undocumented but IMHO the most authenticated way to do it.
-
Demonstrate how to hook the UI building
-
Demonstrate how to get the component from the Qt Designer UI file
-
Demonstrate the usage of model–view–viewmodel (MVVM).
