A very basic project to make it easier to jump-start other PyQt/PySide projects
##Included
- This README.md
- .gitignore for Python apps (modified)
- Uses the excellent qtpy compatibility layer from the guys that make Spyder IDE
- Selection of PyQt API v2
- Begginning wndmain.ui (dynamically loaded)
- Custom PNG icon template with correct exhibition on taskbar
- Simple callback thread example
- CHANGELOG.md example
- Logging utilities using the
logging
default module - Simple run.py to execute simple commands (a little like Make). No dependencies.
- PyInstaller spec file to convert whole program into a single .exe file. This spec file includes:
- Single-file EXE generation
- Multi-resolution conversion of PNG icon to ICO (depends on Pillow)
data
folder automatic inclusion in executablefrozen()
function to facilitate using frozen data files- Exclusion of unused Qt modules (comment if your app uses them)
- Uses UPX if available Note: when using some libraries, you'll need setuptools version 19.2, or the EXE generation might fail.
- Translation i18n support through Qt Linguist. Supports translating (and loading) in multiple languages with the
--lang
option, which defaults to the system's language. - Window position and state saving. Settings are stored in an INI file, which can be used for other program settings.
pip install qtpy
pip install PyInstaller
or
conda install qtpy
pip install PyInstaller
-
Copy the files to your new project's directory.
-
Change the
README.md
file to reflect your project's characteristics. -
Rename
main.py
to<yourproject>.py
andmain.spec
to<yourproject>.spec
if you want. -
Open
<yourproject>.spec
and change thename
variable to your project's name. Also change themain.py
file in the Analysis step to<yourproject>.py
like you renamed in the previous step. -
Open the
<yourproject>.py
file and change the header as you wish, specially the application name, author and LICENSE parts. -
In the bottom of the file, change the
myappid
variable to match your project's details. This is used to set your executable's icon separate from other Python processes in the window manager. -
Trim the unused parts of the project. The Thread and ConsoleHandler usages are just examples for useful features.
-
The window and icon files are in the
data
directory. Put application resources in this directory, so that they will be automatically included when using PyInstaller. Remember to use thefrozen()
function when using those resources' filenames. -
When ready to freeze the app, go to the command line and use:
pyinstaller <yourproject>.spec
- Enjoy!
If your script doesn't build with PyInstaller, try one or more of these in the
<yourproject>.spec
file:
-
Change the
single_file
variable toFalse
. This will put all files in a directory. Looking at the gathered files may help identify missing DLLs. -
In the
EXE()
call, changeconsole=False
toconsole=True
. After that, when running the built executable from the command line, it is possible to see errors and tracebacks that may help find where the problem is. -
If that's not enough, change
debug=False
todebug=True
. This will enable PyInstaller's debug messages which are shown when the program is loading the script.
Remember to revert these changes when the problem is solved.