First, ensure that you have Python installed on your system. You can download Python from python.org.
Next, install the custom widgets module from GitHub using pip:
pip install QT-PyQt-PySide-Custom-Widgets
Remember to also install PySide6, PyQt6,PySide2 or PyQt5(Recommended: PySide6 or PyQt6)
pip install PySide6
Create a new PySide6 project using the custom widgets project maker command:
Custom_Widgets --create-project
Navigate to the project folder that was created.
Inside the project folder, open the ui
folder and start editing the UI using Qt Designer.
While editing the UI, open a terminal inside the project folder and run the following command to monitor UI files for changes:
Custom_Widgets --monitor-ui ui
This will automatically convert UI files to Python and generate necessary files for the custom widgets module.
After finishing the UI design, preview it to ensure everything looks as expected.
Now, add other GUI functions and classes inside the Python files (e.g., main.py
).
Customize and style your GUI using the custom widgets module. This module will read the JSON files and QSS stylesheet files inside the project folder.
Finally, convert your GUI application to an executable using PyInstaller. First, install PyInstaller:
pip install pyinstaller
Next, generate the spec file for your project:
pyi-makespec --onefile --windowed main.py
Open the generated .spec
file and edit it as shown below. Replace names and paths as necessary:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(
['main.py'],
pathex=[], # Add paths if needed
binaries=[],
datas=[], # Add data files if needed
hiddenimports=['PySide6'],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=['PyQt5', 'PySide2', 'PyQt6'],
noarchive=False,
)
pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='YourAppName', # Set the name of your executable
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=False, # Set console to False
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon='path/to/your/icon.ico' # Replace 'path/to/your/icon.ico' with the path to your icon file
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='main',
)
Finally, build the executable using the edited spec file:
pyinstaller your_spec_file.spec
After the build process is complete, the executable will be located in the dist folder inside your project directory. The path will be similar to:
your_project_folder/dist/YourAppName.exe
Note: Remember to copy other required static data files to your exe folder.
Hey there! If you enjoy my projects and find them helpful, consider buying me a coffee. Your support helps me keep going and create more awesome content! 😊