Python: Updating old GUI app to work with the current Custom Widgets module update | PySide/PyQt
INTRO
Join me for a special livestream.
In this livestream I am going to show you how you can easily convert your old PySide or PyQt desktop apps to work with the custom widgets module without any errors
We are going to update this old GUI tutorial from this video.
Steps
Follow the steps listed below if you have been using Custom Widgets Module
version 0.6.8 or earlier versions.
These are the steps were going to follow:
- Install the latest Custom Widgets module
pip install --upgrade QT-PyQt-PySide-Custom-Widgets
- Our GUI also uses an old version of
PySideExtn
that does not supportPySide6
so we will install the new updated version I made(Skip this part if you dont need PySideExtn)pip install PySideExtn
- After installation, create an empty folder.
- Inside this folder, create a new Custom Widgets project by running the command below
Custom_Widgets --create-project
- Follow the onscreen prompt and feel the data you want.
- After the project has been created you can run it to ensure everything is working
- Now open your
old project folder
and copy every file to their respective folder inside thenew project folder
we just created. Ignore the following files:- The
png icons
files previously generated by the custom widget module, if available. - The interface
ui_.... .py
file genated from qt-designer oruic
- Qrc
rc_..... .py
files generated from.qrc
files. -
main.css, _style.scss, and _variables.scss
file inside theQSS
folder(if available). These files will be generated by the custom widgets module.The custom widgets will generate new icons inside the
Qss
folder. Newui
and other files will also be generated.
- The
-
When copying your files, please follow the folder structure described here:
- Do not put anything inside the
generated-files
folder. This should only contain files created at run time. - Put all your
JSon stylesheets
for the custom widgets inside thejson-styles
folder. logs
folder is for log files.- The
Qss
folder is forQt Stylesheet
files. By default, this folder will containicons
andscss
subfolders.- The
scss(Sassy CSS)
folder contains various scss files. Put your default css/scss code inside thedefaultStyle.scss
file. - The
icons
folder containspng icons
and_icons.qrc
files generated by the custom widgets module. - Remember to include the
_icons.qrc
file in your UI files if your want to use the icons.
- The
- Do not put anything inside the
- Feel free to add other files and folders as you wish.
- Now generate new files from your
ui
files. Assuming that you put all your UI files inside the ‘ui’ folder, run the following command to convert the files:Custom_Widgets --convert-ui ui-path --qt-library your-lib
If youre tired of converting the UI files each time you make some changes, you can run a
live files listener
that will automatically convert the ui files for you.Custom_Widgets --monitor-ui ui-path --qt-library your-lib
Replace ‘ui-path’ with you ui path or folder, fo this case the ui folder is ‘ui’. Repace ‘your-lib’ with your qt lib, or remove argument(–qt-library your-lib) if youre using
PySide6
-
Remember to update the
promoted
classes inside the UI files. Also, do not forget to update yourimport
statements inside your python files. - RUN your project.
Be patient, new missing icon files will be generated. View your terminal for
app theme
progress activities.
That’s all. HAPPY CODING
You found this helpful? Support this project
License
MIT
Free Software, Hell Yeah!