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
QtDesignerto drag and drop components and create UI files ->ui/*.ui - Run
workflow.shto automatically generate Python files ->ui/*.py,res/*.py - Inherit from the
ui/*.pyfiles 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 pyside6QtDesigner 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
pyuic6tool allows you to convert design files into Python files, making it more convenient to write code logic. If you don't haveuicinstalled, you can runpyqt6-tools installuicto install it. Additionally, the-xflag generates a standalone executable window, and theecho -e '' > filecommand appends content to the end of the file (the-eflag 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
sedcommand in the command replacesPySide6withPyQt6to 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!
