Welcome to the pyqt6_workflow repository! This project aims to provide a simplified workflow for quickly starting new programs using PyQt6.
Say goodbye to manually writing complex UI layouts. With QtDesigner
, you can easily create layouts through drag-and-drop, with a WYSIWYG (What You See Is What You Get) experience.
- Use
QtDesigner
to drag and drop components and create UI files ->ui/*.ui
- Run
workflow.sh
to automatically generate Python files ->ui/*.py
,res/*.py
- Inherit from the
ui/*.py
files and write corresponding window logic functions ->win/*.py
- Complete application development
To get started, run the following command to install the required dependencies:
pip install pyqt6 pyqt6-tools pyside6
QtDesigner is a powerful tool that allows you to create layouts by dragging and dropping components, eliminating the need for manual layout control code. However, it requires a few additional steps involving uic
and pyside6-rcc
. Don't worry, we provide the following instructions, and the workflow.sh script is already set up to automatically search for files and perform the conversion, so there's no need to manually modify the script.
- Run the following command to make the workflow script executable:
- On Linux:
chmod +x workflow.sh
- For Windows users, please search for the corresponding steps. An automated Windows script will be added in the future.
- On Linux:
Pro Tip: You can open this README.md file in PyCharm and click the adjacent green button to directly run the workflow script.
chmod +x workflow.sh
./workflow.sh
-
designer Use the following command to launch QtDesigner:
pyqt6-tools designer
-
pyuic6 The
pyuic6
tool allows you to convert design files into Python files, making it more convenient to write code logic. If you don't haveuic
installed, you can runpyqt6-tools installuic
to install it. Additionally, the-x
flag generates a standalone executable window, and theecho -e '' > file
command appends content to the end of the file (the-e
flag enables recognition of\n
).Note: The workflow.sh script is already set up to automatically search for files and perform the conversion, so there's no need to manually modify the script.
pyuic6 -x ui/MainWindow.ui -o ui/MainWindow.py && echo -e "\nfrom res import resource_rc" >> ui/MainWindow.py
-
pyside6-rcc This tool converts resource files into Python files, facilitating packaging and usage in QtDesigner. The
sed
command in the command replacesPySide6
withPyQt6
to ensure compatibility.Note: The workflow.sh script is already set up to automatically search for files and perform the conversion, so there's no need to manually modify the script.
pyside6-rcc -g python ./res/resource.qrc | sed '0,/PySide6/s//PyQt6/' > ./res/resource_rc.py
Feel free to explore and make the most of the pyqt6_workflow repository. Happy coding!