Python的界面美化库 qt-material
Python的界面美化库 qt-material
- 1、先看效果
- 2、github地址
- 3、基础用法
1、先看效果
2、github地址
qt-material项目地址:https://github.com/dunderlab/qt-material
示例地址:https://github.com/UN-GCPDS/qt-material
3、基础用法
参考官方文档:https://qt-material.readthedocs.io/en/latest/index.html
本质上就是一个全局的qss,设置应用程序的setStyleSheet
,如下qt-material
的setStyleSheet
源码所示。
def apply_stylesheet(app,theme="",style="Fusion",save_as=None,invert_secondary=False,extra={},parent="theme",css_file=None,
):""""""if style:try:app.setStyle(style)except:logging.warning(f"The style '{style}' does not exist.")passif "QMenu" in extra:for k in extra["QMenu"]:extra[f"qmenu_{k}"] = extra["QMenu"][k]extra["QMenu"] = Truestylesheet = build_stylesheet(theme, invert_secondary, extra, parent)if stylesheet is None:returnif save_as:with open(save_as, "w") as file:file.writelines(stylesheet)if css_file and os.path.exists(css_file):with open(css_file) as file:stylesheet += file.read().format(**os.environ)app.setStyleSheet(stylesheet)