-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for generating qrc file #28
Comments
This is what I am doing so far to generate a qrc file: import os
from pathlib import Path
from jinja2 import Environment, FileSystemLoader, select_autoescape
from qt_material import export_theme
root_path = os.path.abspath('../')
theme_path = os.path.join(root_path, "theme")
qss_path = os.path.join(root_path, "style.qss")
qrc_path = os.path.join(root_path, "style.qrc")
export_theme(theme='dark_teal.xml', qss=qss_path, output=theme_path, prefix=':theme/')
p = Path(theme_path)
files = ['/'.join(a.parts[-3:]) for a in p.glob("**/*.svg")]
env = Environment(loader=FileSystemLoader("."), autoescape=select_autoescape(['html', 'xml']))
template = env.get_template("styles.qrc")
render = template.render(files=files)
with open(qrc_path, 'w') as f:
f.write(render) styles.qrc <!DOCTYPE RCC>
<RCC version="1.0">
<qresource>
{%- for file in files %}
<file>{{ file }}</file>{% endfor %}
</qresource>
<qresource>
<file>style.qss</file>
</qresource>
</RCC> |
There is no reason to use Embed random files into a single Python file is not the proper way to handle resources, both Python and all operating systems has package manager that handle them without problems. I honestly don't recommend using |
I am not too sure if that can be done in C++ though? |
I could get back the |
I am not too sure how the answer in #25 is being used. Because as far as I know qrc files are embedded into the static file. Also, mac being mac, wants to know the path where it could find the icons from. I don't see any other way. Unless I am wrong. |
I just add the export_theme(theme='dark_teal.xml', qss='dark_teal.qss', rcc='resources.rcc',
output='theme', prefix='icon:/', invert_secondary=False, extra=extra) The |
Awesome! Thanks. |
Thank you for adding the generate function in #25
Could you add a way to generate qrc file too? - https://doc.qt.io/qt-6/resources.html
The text was updated successfully, but these errors were encountered: