Compile resource files during configuration.
Added `--compiled-resource` flag, which can be used to invoke `pyrcc5`. The `pyrcc5` executable can be controlled via the `PYRCC5` environment variable or the `--pyrcc5` flag. Updated the documentation to reflect this, including the default build scripts.main
parent
c14c9f657e
commit
09f02a1185
26
README.md
26
README.md
|
@ -177,13 +177,14 @@ Here are detailed instructions on how to install Breeze Style Sheets for a varie
|
||||||
|
|
||||||
## Configuring
|
## Configuring
|
||||||
|
|
||||||
By default, BreezeStyleSheets comes with the `dark` and `light` themes pre-built. In order to build all pre-packaged themes, run:
|
By default, BreezeStyleSheets comes with the `dark` and `light` themes pre-built. In order to build all pre-packaged themes including PyQt5 and PyQt6 support, run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python configure.py --styles=all --extensions=all --resource breeze.qrc
|
python configure.py --styles=all --extensions=all --pyqt6 \
|
||||||
|
--resource breeze.qrc --compiled-resource breeze_resources.py
|
||||||
```
|
```
|
||||||
|
|
||||||
All generated themes will be in the [dist](/dist) subdirectory.
|
All generated themes will be in the [dist](/dist) subdirectory, and the compiled Python resource will be in `breeze_resouces.py`. Note that using the `--compiled-resource` flag requires `pyrcc5` to be installed.
|
||||||
|
|
||||||
## CMake Installation
|
## CMake Installation
|
||||||
|
|
||||||
|
@ -308,11 +309,15 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
## PyQt5 Installation
|
## PyQt5 Installation
|
||||||
|
|
||||||
To compile the stylesheet for use with PyQt5, compile with the following command `pyrcc5 dist/qrc/breeze.qrc -o breeze_resources.py`. `breeze_resources.py` now contains all the stylesheet data. To load and set the stylesheet in a PyQt5 application, import `breeze_resources`, load the file using QFile and read the data. For example, to load BreezeDark, run:
|
To compile the stylesheet for use with PyQt5, ensure you configure with the `--compiled-resource` flag (which requires `pyrcc5` installed). The compiled resource Python file now contains all the stylesheet data. To load and set the stylesheet in a PyQt5 application, import that file, load the contents using QFile and read the data. For example, to load BreezeDark, first configure using:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python configure.py --compiled-resource breeze_resources.py
|
||||||
|
```
|
||||||
|
|
||||||
|
Then load the stylesheet and run the application using:
|
||||||
|
|
||||||
```python
|
```python
|
||||||
|
|
||||||
from PyQt5 import QtWidgets
|
from PyQt5 import QtWidgets
|
||||||
from PyQt5.QtCore import QFile, QTextStream
|
from PyQt5.QtCore import QFile, QTextStream
|
||||||
import breeze_resources
|
import breeze_resources
|
||||||
|
@ -416,7 +421,11 @@ Have an issue with the styles? Here's a few suggestions, prior to filing a bug r
|
||||||
|
|
||||||
## Configuring
|
## Configuring
|
||||||
|
|
||||||
To configure the assets and the stylesheets, run `configure.py`. To compile the assets and stylesheets for Python, run `pyrcc5 dist/qrc/breeze.qrc -o breeze_resources.py`.
|
To configure the assets and the stylesheets, run `python configure.py`. To compile the assets and stylesheets for PyQt5, ensure `pyrcc5` is installed and run:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
python configure.py --compiled-resource breeze_resources.py
|
||||||
|
```
|
||||||
|
|
||||||
## Testing
|
## Testing
|
||||||
|
|
||||||
|
@ -424,10 +433,11 @@ In order to test your changes, first run the tests using the appropriate widget
|
||||||
|
|
||||||
## Distribution Files
|
## Distribution Files
|
||||||
|
|
||||||
When pushing changes, only the `light` and `dark` themes should be configured, without any extensions. To reset the built resource files to the defaults, run:
|
When pushing changes, only the `light` and `dark` themes should be configured, without any extensions. To reset the built resource files to the defaults (this requires `pyrcc5` to be installed), run:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
python configure.py --clean --pyqt6
|
python configure.py --clean --pyqt6 \
|
||||||
|
--compiled-resource breeze_resources.py
|
||||||
```
|
```
|
||||||
|
|
||||||
If no changes are being made to the icons or stylesheets, you may want to ensure that the `dist` directory is assumed to be unchanged in git, no longer tracking changes to these files. You can turn tracking distribution files off with:
|
If no changes are being made to the icons or stylesheets, you may want to ensure that the `dist` directory is assumed to be unchanged in git, no longer tracking changes to these files. You can turn tracking distribution files off with:
|
||||||
|
|
28
configure.py
28
configure.py
|
@ -13,6 +13,7 @@ import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
import shutil
|
import shutil
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
home = os.path.dirname(os.path.realpath(__file__))
|
home = os.path.dirname(os.path.realpath(__file__))
|
||||||
|
@ -63,6 +64,15 @@ def parse_args(argv=None):
|
||||||
help='clean dist directory prior to configuring themes.',
|
help='clean dist directory prior to configuring themes.',
|
||||||
action='store_true'
|
action='store_true'
|
||||||
)
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--pyrcc5',
|
||||||
|
help='name of the pyrcc5 executable. Overridden by the `PYRCC5` envvar.',
|
||||||
|
default='pyrcc5',
|
||||||
|
)
|
||||||
|
parser.add_argument(
|
||||||
|
'--compiled-resource',
|
||||||
|
help='output compiled python resource file.',
|
||||||
|
)
|
||||||
args = parser.parse_args(argv)
|
args = parser.parse_args(argv)
|
||||||
parse_styles(args)
|
parse_styles(args)
|
||||||
parse_extensions(args)
|
parse_extensions(args)
|
||||||
|
@ -322,9 +332,25 @@ def configure(args):
|
||||||
for style in config['themes'].keys():
|
for style in config['themes'].keys():
|
||||||
configure_style(config, style)
|
configure_style(config, style)
|
||||||
|
|
||||||
|
# Create and compile our resource files.
|
||||||
|
# resource files aren't used in PyQt6: no rcc6 anyway.
|
||||||
if not args.no_qrc:
|
if not args.no_qrc:
|
||||||
# resource files aren't used in PyQt6: no rcc6 anyway.
|
|
||||||
write_qrc(config)
|
write_qrc(config)
|
||||||
|
if not args.no_qrc and args.compiled_resource is not None:
|
||||||
|
pyrcc5 = os.environ.get('PYRCC5', args.pyrcc5)
|
||||||
|
command = [
|
||||||
|
pyrcc5,
|
||||||
|
f'{qrc_dist}/{args.resource}',
|
||||||
|
'-o',
|
||||||
|
f'{home}/{args.compiled_resource}'
|
||||||
|
]
|
||||||
|
subprocess.check_call(
|
||||||
|
command,
|
||||||
|
stdin=subprocess.DEVNULL,
|
||||||
|
stdout=subprocess.DEVNULL,
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
shell=False,
|
||||||
|
)
|
||||||
|
|
||||||
def main(argv=None):
|
def main(argv=None):
|
||||||
'''Configuration entry point'''
|
'''Configuration entry point'''
|
||||||
|
|
Loading…
Reference in New Issue