Welcome to Qt Dev Helper’s documentation!
Qt Dev Helper
Toolbox to help develop Qt applications, improving the usability of the existing tooling.
Installation
pip install qt-dev-helper
OR
conda install -c conda-forge qt-dev-helper
Features
Usable as Library and/or CLI tool
Compatible with PEP517 build system (see test case)
CLI auto completion
Project wide configuration in
pyproject.toml
Recursive asset compiler for Qt projects (using
uic
andrcc
):*.ui
->*.py
*.qrc
->*.py
*.ui
->*.h
*.qrc
->*.h
*.scss
->*.qss
Support for multiple Qt tooling suppliers
PySide6-Essentials
qt6-applications
qt5-applications
Ability to open all files in a folder in QtDesigner
Planned features
Stand alone executable for each release (Windows)
File watch mode
qss
injection into*.ui
filespre-commit
hooks
FAQ
Q: Why is
PyQt5
not supported?A:
PyQt5
only ships a python specific version ofuic
andrcc
breaking the tool API and compatibility with cpp projects. Use the matching version ofqt5-applications
as Qt tooling supplier.
Contributors ✨
Thanks goes out to these wonderful people (emoji key):
Sebastian Weigand 💻 🤔 🚧 📆 🚇 ⚠️ 📖 |
Joris Snellenburg 👀 |
This project follows the all-contributors specification. Contributions of any kind are welcome!
Installation
Stable release
To install Qt Dev Helper, run this command in your terminal:
$ pip install qt_dev_helper
This is the preferred method to install Qt Dev Helper, as it will always install the most recent stable release.
If you don’t have pip installed, this Python installation guide can guide you through the process.
From sources
The sources for Qt Dev Helper can be downloaded from the Github repo.
You can either clone the public repository:
$ git clone git://github.com/s-weigand/qt-dev-helper
Or download the tarball:
$ curl -OJL https://github.com/s-weigand/qt-dev-helper/tarball/main
Once you have a copy of the source, you can install it with:
$ python setup.py install
Usage
To use Qt Dev Helper in a project:
import qt_dev_helper
Command-line Interface
qt-dev-helper
Collection of CLI commands to improve workflows when developing Qt GUI Applications.
qt-dev-helper [OPTIONS] COMMAND [ARGS]...
Options
- --install-completion <install_completion>
Install completion for the specified shell.
- Options:
bash | zsh | fish | powershell | pwsh
- --show-completion <show_completion>
Show completion for the specified shell, to copy it or customize the installation.
- Options:
bash | zsh | fish | powershell | pwsh
build
Build production assets from input files.
qt-dev-helper build [OPTIONS] [BASE_PATH]
Options
- -c, --config <config>
Path to a config file.
- -r, --recurse-folder
Recurse directories searching for files.
- Default:
False
- -g, --generator <generator>
Code generator used to compile ui and resource files.
- Options:
python | cpp
- --flatten-folder-structure, --no-flatten-folder-structure
Whether or not to flatten the folder structure of the ui and resource files.
- --generated-ui-code-folder <generated_ui_code_folder>
Root folder to save code generated from *.ui files to.
- --uic-args <uic_args>
Additional arguments for the uic executable, as comma separated list.
- --generated-rc-code-folder <generated_rc_code_folder>
Root folder to save code generated from *.qrc files to.
- --form-import, --no-form-import
Python: generate imports relative to ‘.’
- --rcc-args <rcc_args>
Additional arguments for the rcc executable, as comma separated list.
- --root-sass-file <root_sass_file>
Scss stylesheet with the style for the whole application.
- --root-qss-file <root_qss_file>
Qss stylesheet with the style for the whole application, generated from ‘root_sass_file’.
Arguments
- BASE_PATH
Optional argument
designer
Open *.ui files in qt-designer.
qt-dev-helper designer [OPTIONS] [FILES]...
Options
- --recurse-folder, --no-recurse-folder
Whether or not to recurse directories searching for files.
- Default:
True
- --open-files, --no-open-files
Whether or not to open files.
- Default:
True
Arguments
- FILES
Optional argument(s)
Configuration
- pydantic settings Config[source]
Project configuration.
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Show JSON schema
{ "title": "Config", "description": "Project configuration.", "type": "object", "properties": { "base_path": { "title": "Base Path", "description": "Directory the config was loaded from, used to resolve relative paths.", "env_names": "{'base_path'}", "type": "string", "format": "path" }, "root_sass_file": { "title": "Root Sass File", "description": "Scss stylesheet with the style for the whole application.", "env_names": "{'root_sass_file'}", "type": "string" }, "root_qss_file": { "title": "Root Qss File", "description": "Qss stylesheet with the style for the whole application, generated from 'root_sass_file'.", "env_names": "{'root_qss_file'}", "type": "string" }, "generator": { "description": "Code generator used to compile ui and resource files.", "default": "python", "env_names": "{'generator'}", "allOf": [ { "$ref": "#/definitions/CodeGenerators" } ] }, "flatten_folder_structure": { "title": "Flatten Folder Structure", "description": "Whether to keep the original folder structure or flatten it.", "default": true, "env_names": "{'flatten_folder_structure'}", "type": "boolean" }, "ui_files_folder": { "title": "Ui Files Folder", "description": "Root folder containing *.ui files.", "env_names": "{'ui_files_folder'}", "type": "string" }, "generated_ui_code_folder": { "title": "Generated Ui Code Folder", "description": "Root folder to save code generated from *.ui files to.", "env_names": "{'generated_ui_code_folder'}", "type": "string" }, "uic_args": { "title": "Uic Args", "description": "Additional arguments for the uic executable.", "env_names": "{'uic_args'}", "type": "array", "items": { "type": "string" } }, "form_import": { "title": "Form Import", "description": "Python: generate imports relative to '.'", "default": true, "env_names": "{'form_import'}", "type": "boolean" }, "resource_folder": { "title": "Resource Folder", "description": "Root folder containing *.qrc files.", "env_names": "{'resource_folder'}", "type": "string" }, "generated_rc_code_folder": { "title": "Generated Rc Code Folder", "description": "Root folder to save code generated from *.qrc files to.", "env_names": "{'generated_rc_code_folder'}", "type": "string" }, "rcc_args": { "title": "Rcc Args", "description": "Additional arguments for the rcc executable.", "env_names": "{'rcc_args'}", "type": "array", "items": { "type": "string" } } }, "required": [ "base_path" ], "additionalProperties": false, "definitions": { "CodeGenerators": { "title": "CodeGenerators", "description": "Valid code generator values.", "enum": [ "python", "cpp" ], "type": "string" } } }
- Fields:
- Validators:
_validate_rc_input_path
»resource_folder
_validate_rc_io
»all fields
_validate_style_input_path
»root_sass_file
_validate_styles_io
»all fields
_validate_ui_input_path
»ui_files_folder
_validate_ui_io
»all fields
- field base_path: Path [Required]
Directory the config was loaded from, used to resolve relative paths.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field flatten_folder_structure: bool = True
Whether to keep the original folder structure or flatten it.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field form_import: bool = True
Python: generate imports relative to ‘.’
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field generated_rc_code_folder: str | None = None
Root folder to save code generated from *.qrc files to.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field generated_ui_code_folder: str | None = None
Root folder to save code generated from *.ui files to.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field generator: CodeGenerators = CodeGenerators.python
Code generator used to compile ui and resource files.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field rcc_args: List[str] [Optional]
Additional arguments for the rcc executable.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field resource_folder: str | None = None
Root folder containing *.qrc files.
- Validated by:
_validate_rc_input_path
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field root_qss_file: str | None = None
Qss stylesheet with the style for the whole application, generated from ‘root_sass_file’.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- field root_sass_file: str | None = None
Scss stylesheet with the style for the whole application.
- Validated by:
_validate_rc_io
_validate_style_input_path
_validate_styles_io
_validate_ui_io
- field ui_files_folder: str | None = None
Root folder containing *.ui files.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_input_path
_validate_ui_io
- field uic_args: List[str] [Optional]
Additional arguments for the uic executable.
- Validated by:
_validate_rc_io
_validate_styles_io
_validate_ui_io
- rc_folder_paths() Tuple[Path, Path] [source]
Resolve paths to root style files.
- Returns:
Paths to
resource_folder
andgenerated_rc_code_folder
.- Return type:
Tuple[Path, Path]
- rcc_kwargs() RccKwargs [source]
Extract keyword arguments to be used with
compile_resource_file
.- Returns:
Keyword arguments for
compile_resource_file
.- Return type:
- root_style_paths() Tuple[Path, Path] [source]
Resolve paths to root style files.
- Returns:
Paths to
root_sass_file
androot_qss_file
.- Return type:
Tuple[Path, Path]
- ui_folder_paths() Tuple[Path, Path] [source]
Resolve paths to root style files.
- Returns:
Paths to
ui_files_folder
andgenerated_ui_code_folder
.- Return type:
Tuple[Path, Path]
Inner workings
This is the detailed documentation of the inner workings of qt_dev_helper
.
Top-level package for Qt Dev Helper. |
Contributing
Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.
You can contribute in many ways:
Types of Contributions
Report Bugs
Report bugs at https://github.com/s-weigand/qt-dev-helper/issues.
If you are reporting a bug, please include:
Your operating system name and version.
Any details about your local setup that might be helpful in troubleshooting.
Detailed steps to reproduce the bug.
Fix Bugs
Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.
Implement Features
Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.
Write Documentation
Qt Dev Helper could always use more documentation, whether as part of the official Qt Dev Helper docs, in docstrings, or even on the web in blog posts, articles, and such.
Submit Feedback
The best way to send feedback is to file an issue at https://github.com/s-weigand/qt-dev-helper/issues.
If you are proposing a feature:
Explain in detail how it would work.
Keep the scope as narrow as possible, to make it easier to implement.
Remember that this is a volunteer-driven project, and that contributions are welcome :)
Get Started!
Ready to contribute? Here’s how to set up qt_dev_helper
for local development.
Fork the
qt-dev-helper
repo on GitHub.Clone your fork locally:
$ git clone git@github.com:your_name_here/qt_dev_helper.git
Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:
$ mkvirtualenv qt_dev_helper $ cd qt-dev-helper/ $ pip install -e .
install the
pre-commit
andpre-push
hooks:$ pre-commit install && pre-commit install -t pre-push
Create a branch for local development:
$ git checkout -b name-of-your-bugfix-or-feature
Now you can make your changes locally.
When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:
$ tox
To get flake8 and tox, just pip install them into your virtualenv.
Commit your changes and push your branch to GitHub:
$ git add . $ git commit -m "Your detailed description of your changes." $ git push origin name-of-your-bugfix-or-feature
Submit a pull request through the GitHub website.
Pull Request Guidelines
Before you submit a pull request, check that it meets these guidelines:
The pull request should include tests.
If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.md.
The pull request should work for Python 3.8, 3.9 and 3.10. Check https://github.com/s-weigand/qt-dev-helper/actions and make sure that the tests pass for all supported Python versions.
Tips
To run a subset of tests:
$ pytest tests.test_qt_dev_helper
Deploying
A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:
$ bump2version patch # possible: major / minor / patch
$ git push --follow-tags
Travis will then deploy to PyPI if tests pass.
Changelog
0.0.4 (2023-07-08)
📚🩹 Fix missing CLI docs on RTD by @s-weigand in (#63)
🚇👌 Add py3.11 CI tests and ⬆️ autoupdate pre-commit config by @s-weigand in (#69)
📚 Improve readme by @s-weigand in (#70)
📦 Pin pydantic to version <2 by @s-weigand in (#115)
0.0.3 (2022-09-05)
🗑️ Removed qtsass310 dependency in favor of qtsass>=0.3.1 (#54)
0.0.2 (2022-09-05)
👌 Use extended path when calling Qt tools and add folder containing lib files (#52)
0.0.1 (2022-09-04)
🚀 First release on PyPI.