pyqt6rc
This library offers scripts to correct resource paths in files generated by the pyuic6 command.
Since PyQt6 does not include the pyrcc6 script for converting resources, this package serves that purpose.
In the current PyQt6 implementation, the .py files created by the pyuic6 command contain incorrect resource paths.
UPDATE: As of PyQt-6.3.1 it's possible to use Qt’s resource system again.
We can use pyside6-rcc to convert rcc files into py.
Source for this solution can be found in StackOverflow answer.
Provided scripts are converting .ui files into .py files using three different ways:
- Using
pyside6-rccscript to convertrccfiles intopyandpyuic6to convert alluifiles [Use pyside6rc] - Native >= python3.7 solution using importlib [Use pyqt6rc].
- Use of importlib_resources, for compatibility with Python3.6+ [Use pyqt6rc with -c option]
- Adding resource search path using
QtCore.QDir.addSearchPath()and modifying generated prefixes [Use pyqt6sp]
More on this topic can be found on StackOverflow.
From version 4.0, parameter -p, --package was removed. Pyqt6rc now determines package name automatically by crawling
parent folders and looking for \_\_init\_\_.py file.
Conversion
Generated template using pyside6rc script:
import myPackage.resources.icons # noqa
Generated template using pyuic6 script:
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap(":/icons/icon1.png"), QtGui.QIcon.Mode.Normal, QtGui.QIcon.State.Off)
Generated template using pyqt6rc script:
from importlib.resources import path
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)
Generated template using pyqt6rc (-c, --compatible) script:
from importlib_resources import path
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)
Generated template using pyqt6sp script:
import os
from os.path import dirname, normpath
from PyQt6.QtCore import QDir
prefix_resources = [('icons', '../resources/')]
for prefix, resource in prefix_resources:
sp = QDir.searchPaths(prefix)
QDir.setSearchPaths(prefix, set(sp + [normpath(os.path.join(dirname(__file__), resource))]))
icon = QtGui.QIcon()
icon.addPixmap(QtGui.QPixmap("icons:icon1.png"), 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
Batch convert all .ui files located in the templates directory using pyside6-rcc
pyside6rc /myPackage/templates
Batch convert all .ui files located in the templates directory using pyside6-rcc
Without writing import line of resource package to ui files (-niw)
pyside6rc -niw /myPackage/templates
Batch convert all .ui files located in the templates directory using pyside6-rcc
Without ui to py conversion (-npc)
pyside6rc -npc /myPackage/templates
Batch convert all .ui files located in the templates directory using pyside6-rcc
pyside6-rcc /myPackage/templates
Batch convert all .ui files located in the templates directory
pyqt6rc /myPackage/templates
Convert template1.ui only
pyqt6rc /myPackage/templates/template1.ui
Convert template1.ui and save it in /tmp directory
pyqt6rc /myPackage/templates/template1.ui -o /tmp
Batch convert all .ui files located in templates directory using importlib_resources
pyqt6rc /myPackage/templates -c
Batch convert all .ui files located in templates directory using setSearchPaths method
pyqt6sp /myPackage/templates
Metadata
Release files for pyqt6rc 0.7.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| pyqt6rc-0.7.1.tar.gz | 15.7 kB | Without provenance | Details for pyqt6rc-0.7.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| pyqt6rc-0.7.1-py3-none-any.whl | Python 3 | none | any | Details for pyqt6rc-0.7.1-py3-none-any.whl |
Total release size: 51.5 kB
Release files / pyqt6rc-0.7.1.tar.gz
| Download URL | pyqt6rc-0.7.1.tar.gz |
|---|---|
| Size | 15.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3658c741db719e4e0aa32fc6a43bbfae0776f3f83f7fd8449edd6865c2b8a66d
|
|
BLAKE2b-256 checksum How to use checksums |
ccc49984a489a2007c25d4ba896a398242f21f47e64a50981019d0df1c7fe03d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.9.6 Darwin/24.4.0
|
Release files / pyqt6rc-0.7.1-py3-none-any.whl
| Download URL | pyqt6rc-0.7.1-py3-none-any.whl |
|---|---|
| Size | 35.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8c0ed816f7c9714af5c6715cfbb079fb936521cf82d4c045e4c6ae8d65c861fa
|
|
BLAKE2b-256 checksum How to use checksums |
b45ad9401daf1a9d39330fc7bf3e4b7a66e1aecdf2b4b96a5a7bebd779299dc8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.8.4 CPython/3.9.6 Darwin/24.4.0
|
Security for pyqt6rc 0.7.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.