PyQt6 UI templates resource converter
Project description
pyqt6rc
Script to convert resource paths generated by QT6 designer.
PyQt6 does not provide pyrcc6 script to convert resources.
In current PyQt6 implementation, files created by pyuic6 scripts using Qt resources has wrong path.
This script is converting .ui files into .py files and using importlib to fix resource path.
There are multiple solutions to this problem:
- One is to use QtCore.QDir.addSearchPath().
But still path generated by designer does not follow pattern "prefix:path". - Use of importlib_resources, which is third party library.
- Native python3.7+ solution using importlib, which is adopted by this script.
Conversion
Generated template by pyuic6:
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icon1.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
Generated template by pyqt6rc script:
icon = QtGui.QIcon()
with path("myPackage.resources.icons", "icon1.png") as f_path:
icon.addPixmap(QtGui.QPixmap(str(f_path)), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
Usage examples
Package structure example
myPackage
│ __init__.py
│
└───resources
| | __init__.py
│ │ image1.png
│ │ image2.png
│ │ resources.qrc
| | ...
| |
| └───icons
│ │ __init__.py
│ │ icon1.png
│ │ icon2.png
│ │ ...
│
└───templates
│ template1.ui
│ template2.ui
Convert all .ui files located in templates directory
pyqt6rc /myPackage/resources/resources.qrc -p myPackage.resources -i /myPackage/templates
Convert template1.ui
pyqt6rc /myPackage/resources/resources.qrc -p myPackage.resources -i /myPackage/templates/template1.ui
Convert template1.ui and save it in /tmp directory
pyqt6rc /myPackage/resources/resources.qrc -p myPackage.resources -i /myPackage/templates/template1.ui -o /tmp
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pyqt6rc-0.1.1.tar.gz.
File metadata
- Download URL: pyqt6rc-0.1.1.tar.gz
- Upload date:
- Size: 9.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
405b8d283d29c184e54ac2191009e152373d30597d2b5e1e6351c980c6951a4e
|
|
| MD5 |
dfebfb6be88293de00e5be20f0040946
|
|
| BLAKE2b-256 |
7ed75937462174cbbba9320f09cee0cfad30740e7caf3de266a229fffc269cc5
|
File details
Details for the file pyqt6rc-0.1.1-py3-none-any.whl.
File metadata
- Download URL: pyqt6rc-0.1.1-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.22.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba7e874f260fc943b03911875e88b463bb6e03c9e0f84b9ddf8226f5d62d6126
|
|
| MD5 |
dc6812ca5d9a779f336fb75dfac850a8
|
|
| BLAKE2b-256 |
669c8358bc604a6cd04beca43722eb1516c5e379140d241fb0425c8ccce8efe0
|