style_sheet =========== .. py:module:: qfluentwidgets.common.style_sheet Module Contents --------------- .. autoapisummary:: qfluentwidgets.common.style_sheet.StyleSheetManager qfluentwidgets.common.style_sheet.QssTemplate qfluentwidgets.common.style_sheet.StyleSheetBase qfluentwidgets.common.style_sheet.FluentStyleSheet qfluentwidgets.common.style_sheet.StyleSheetFile qfluentwidgets.common.style_sheet.CustomStyleSheet qfluentwidgets.common.style_sheet.CustomStyleSheetWatcher qfluentwidgets.common.style_sheet.DirtyStyleSheetWatcher qfluentwidgets.common.style_sheet.StyleSheetCompose qfluentwidgets.common.style_sheet.ThemeColor .. autoapisummary:: qfluentwidgets.common.style_sheet.applyThemeColor qfluentwidgets.common.style_sheet.renderQss qfluentwidgets.common.style_sheet.getStyleSheetFromFile qfluentwidgets.common.style_sheet.getStyleSheet qfluentwidgets.common.style_sheet.setStyleSheet qfluentwidgets.common.style_sheet.setCustomStyleSheet qfluentwidgets.common.style_sheet.addStyleSheet qfluentwidgets.common.style_sheet.updateStyleSheet qfluentwidgets.common.style_sheet.setTheme qfluentwidgets.common.style_sheet.toggleTheme qfluentwidgets.common.style_sheet.themeColor qfluentwidgets.common.style_sheet.setThemeColor .. autoapisummary:: qfluentwidgets.common.style_sheet.styleSheetManager .. py:class:: StyleSheetManager Bases: :py:obj:`PyQt5.QtCore.QObject` Style sheet manager .. py:attribute:: widgets .. py:method:: register(source, widget: PyQt5.QtWidgets.QWidget, reset=True) register widget to manager Parameters ---------- source: str | StyleSheetBase qss source, it could be: * `str`: qss file path * `StyleSheetBase`: style sheet instance widget: QWidget the widget to set style sheet reset: bool whether to reset the qss source .. py:method:: deregister(widget: PyQt5.QtWidgets.QWidget) deregister widget from manager .. py:method:: items() .. py:method:: source(widget: PyQt5.QtWidgets.QWidget) get the qss source of widget .. py:data:: styleSheetManager .. py:class:: QssTemplate(template) Bases: :py:obj:`string.Template` style sheet template .. py:attribute:: delimiter :value: '--' .. py:function:: applyThemeColor(qss: str) apply theme color to style sheet Parameters ---------- qss: str the style sheet string to apply theme color, the substituted variable should be equal to the value of `ThemeColor` and starts width `--`, i.e `--ThemeColorPrimary` .. py:function:: renderQss(qss: str) render font and theme color to style sheet Parameters ---------- qss: str the style sheet string to apply theme color, the substituted variable should be equal to the value of `ThemeColor` and starts width `--`, i.e `--ThemeColorPrimary` .. py:class:: StyleSheetBase Style sheet base class .. py:method:: path(theme=Theme.AUTO) :abstractmethod: get the path of style sheet .. py:method:: content(theme=Theme.AUTO) get the content of style sheet .. py:method:: apply(widget: PyQt5.QtWidgets.QWidget, theme=Theme.AUTO) apply style sheet to widget .. py:class:: FluentStyleSheet Bases: :py:obj:`StyleSheetBase`, :py:obj:`enum.Enum` Fluent style sheet .. py:attribute:: MENU :value: 'menu' .. py:attribute:: LABEL :value: 'label' .. py:attribute:: PIVOT :value: 'pivot' .. py:attribute:: BUTTON :value: 'button' .. py:attribute:: DIALOG :value: 'dialog' .. py:attribute:: SLIDER :value: 'slider' .. py:attribute:: INFO_BAR :value: 'info_bar' .. py:attribute:: SPIN_BOX :value: 'spin_box' .. py:attribute:: TAB_VIEW :value: 'tab_view' .. py:attribute:: TOOL_TIP :value: 'tool_tip' .. py:attribute:: CHECK_BOX :value: 'check_box' .. py:attribute:: COMBO_BOX :value: 'combo_box' .. py:attribute:: FLIP_VIEW :value: 'flip_view' .. py:attribute:: LINE_EDIT :value: 'line_edit' .. py:attribute:: LIST_VIEW :value: 'list_view' .. py:attribute:: TREE_VIEW :value: 'tree_view' .. py:attribute:: INFO_BADGE :value: 'info_badge' .. py:attribute:: PIPS_PAGER :value: 'pips_pager' .. py:attribute:: TABLE_VIEW :value: 'table_view' .. py:attribute:: CARD_WIDGET :value: 'card_widget' .. py:attribute:: TIME_PICKER :value: 'time_picker' .. py:attribute:: COLOR_DIALOG :value: 'color_dialog' .. py:attribute:: MEDIA_PLAYER :value: 'media_player' .. py:attribute:: SETTING_CARD :value: 'setting_card' .. py:attribute:: TEACHING_TIP :value: 'teaching_tip' .. py:attribute:: FLUENT_WINDOW :value: 'fluent_window' .. py:attribute:: SWITCH_BUTTON :value: 'switch_button' .. py:attribute:: MESSAGE_DIALOG :value: 'message_dialog' .. py:attribute:: STATE_TOOL_TIP :value: 'state_tool_tip' .. py:attribute:: CALENDAR_PICKER :value: 'calendar_picker' .. py:attribute:: FOLDER_LIST_DIALOG :value: 'folder_list_dialog' .. py:attribute:: SETTING_CARD_GROUP :value: 'setting_card_group' .. py:attribute:: EXPAND_SETTING_CARD :value: 'expand_setting_card' .. py:attribute:: NAVIGATION_INTERFACE :value: 'navigation_interface' .. py:method:: path(theme=Theme.AUTO) get the path of style sheet .. py:class:: StyleSheetFile(path: str) Bases: :py:obj:`StyleSheetBase` Style sheet file .. py:attribute:: filePath .. py:method:: path(theme=Theme.AUTO) get the path of style sheet .. py:class:: CustomStyleSheet(widget: PyQt5.QtWidgets.QWidget) Bases: :py:obj:`StyleSheetBase` Custom style sheet .. py:attribute:: DARK_QSS_KEY :value: 'darkCustomQss' .. py:attribute:: LIGHT_QSS_KEY :value: 'lightCustomQss' .. py:method:: path(theme=Theme.AUTO) get the path of style sheet .. py:property:: widget .. py:method:: __eq__(other: object) -> bool .. py:method:: setCustomStyleSheet(lightQss: str, darkQss: str) set custom style sheet in light and dark theme mode .. py:method:: setLightStyleSheet(qss: str) set the style sheet in light mode .. py:method:: setDarkStyleSheet(qss: str) set the style sheet in dark mode .. py:method:: lightStyleSheet() -> str .. py:method:: darkStyleSheet() -> str .. py:method:: content(theme=Theme.AUTO) -> str get the content of style sheet .. py:class:: CustomStyleSheetWatcher Bases: :py:obj:`PyQt5.QtCore.QObject` Custom style sheet watcher .. py:method:: eventFilter(obj: PyQt5.QtWidgets.QWidget, e: PyQt5.QtCore.QEvent) .. py:class:: DirtyStyleSheetWatcher Bases: :py:obj:`PyQt5.QtCore.QObject` Dirty style sheet watcher .. py:method:: eventFilter(obj: PyQt5.QtWidgets.QWidget, e: PyQt5.QtCore.QEvent) .. py:class:: StyleSheetCompose(sources: List[StyleSheetBase]) Bases: :py:obj:`StyleSheetBase` Style sheet compose .. py:attribute:: sources .. py:method:: content(theme=Theme.AUTO) get the content of style sheet .. py:method:: add(source: StyleSheetBase) add style sheet source .. py:method:: remove(source: StyleSheetBase) remove style sheet source .. py:function:: getStyleSheetFromFile(file: Union[str, PyQt5.QtCore.QFile]) get style sheet from qss file .. py:function:: getStyleSheet(source: Union[str, StyleSheetBase], theme=Theme.AUTO) get style sheet Parameters ---------- source: str | StyleSheetBase qss source, it could be: * `str`: qss file path * `StyleSheetBase`: style sheet instance theme: Theme the theme of style sheet .. py:function:: setStyleSheet(widget: PyQt5.QtWidgets.QWidget, source: Union[str, StyleSheetBase], theme=Theme.AUTO, register=True) set the style sheet of widget Parameters ---------- widget: QWidget the widget to set style sheet source: str | StyleSheetBase qss source, it could be: * `str`: qss file path * `StyleSheetBase`: style sheet instance theme: Theme the theme of style sheet register: bool whether to register the widget to the style manager. If `register=True`, the style of the widget will be updated automatically when the theme changes .. py:function:: setCustomStyleSheet(widget: PyQt5.QtWidgets.QWidget, lightQss: str, darkQss: str) set custom style sheet Parameters ---------- widget: QWidget the widget to add style sheet lightQss: str style sheet used in light theme mode darkQss: str style sheet used in light theme mode .. py:function:: addStyleSheet(widget: PyQt5.QtWidgets.QWidget, source: Union[str, StyleSheetBase], theme=Theme.AUTO, register=True) add style sheet to widget Parameters ---------- widget: QWidget the widget to set style sheet source: str | StyleSheetBase qss source, it could be: * `str`: qss file path * `StyleSheetBase`: style sheet instance theme: Theme the theme of style sheet register: bool whether to register the widget to the style manager. If `register=True`, the style of the widget will be updated automatically when the theme changes .. py:function:: updateStyleSheet(lazy=False) update the style sheet of all fluent widgets Parameters ---------- lazy: bool whether to update the style sheet lazily, set to `True` will accelerate theme switching .. py:function:: setTheme(theme: qfluentwidgets.common.config.Theme, save=False, lazy=False) set the theme of application Parameters ---------- theme: Theme theme mode save: bool whether to save the change to config file lazy: bool whether to update the style sheet lazily, set to `True` will accelerate theme switching .. py:function:: toggleTheme(save=False, lazy=False) toggle the theme of application Parameters ---------- save: bool whether to save the change to config file lazy: bool whether to update the style sheet lazily, set to `True` will accelerate theme switching .. py:class:: ThemeColor Bases: :py:obj:`enum.Enum` Theme color type .. py:attribute:: PRIMARY :value: 'ThemeColorPrimary' .. py:attribute:: DARK_1 :value: 'ThemeColorDark1' .. py:attribute:: DARK_2 :value: 'ThemeColorDark2' .. py:attribute:: DARK_3 :value: 'ThemeColorDark3' .. py:attribute:: LIGHT_1 :value: 'ThemeColorLight1' .. py:attribute:: LIGHT_2 :value: 'ThemeColorLight2' .. py:attribute:: LIGHT_3 :value: 'ThemeColorLight3' .. py:method:: name() The name of the Enum member. .. py:method:: color() .. py:function:: themeColor() get theme color .. py:function:: setThemeColor(color, save=False, lazy=False) set theme color Parameters ---------- color: QColor | Qt.GlobalColor | str theme color save: bool whether to save to change to config file lazy: bool whether to update the style sheet lazily