common ====== .. py:module:: qfluentwidgets.common .. toctree:: :titlesonly: :maxdepth: 1 animation/index.rst auto_wrap/index.rst color/index.rst config/index.rst exception_handler/index.rst font/index.rst icon/index.rst image_utils/index.rst overload/index.rst router/index.rst screen/index.rst smooth_scroll/index.rst style_sheet/index.rst theme_listener/index.rst translator/index.rst Package Contents ---------------- .. autoapisummary:: qfluentwidgets.common.Theme qfluentwidgets.common.ConfigValidator qfluentwidgets.common.RangeValidator qfluentwidgets.common.OptionsValidator qfluentwidgets.common.BoolValidator qfluentwidgets.common.FolderValidator qfluentwidgets.common.FolderListValidator qfluentwidgets.common.ColorValidator qfluentwidgets.common.ConfigSerializer qfluentwidgets.common.EnumSerializer qfluentwidgets.common.ColorSerializer qfluentwidgets.common.ConfigItem qfluentwidgets.common.RangeConfigItem qfluentwidgets.common.OptionsConfigItem qfluentwidgets.common.ColorConfigItem qfluentwidgets.common.QConfig qfluentwidgets.common.TextWrap qfluentwidgets.common.Action qfluentwidgets.common.Icon qfluentwidgets.common.FluentIcon qfluentwidgets.common.FluentIconBase qfluentwidgets.common.FluentFontIconBase qfluentwidgets.common.ThemeColor qfluentwidgets.common.FluentStyleSheet qfluentwidgets.common.StyleSheetBase qfluentwidgets.common.StyleSheetFile qfluentwidgets.common.StyleSheetCompose qfluentwidgets.common.CustomStyleSheet qfluentwidgets.common.SmoothScroll qfluentwidgets.common.SmoothMode qfluentwidgets.common.FluentTranslator qfluentwidgets.common.Router qfluentwidgets.common.FluentThemeColor qfluentwidgets.common.FluentSystemColor qfluentwidgets.common.SystemThemeListener .. autoapisummary:: qfluentwidgets.common.exceptionHandler qfluentwidgets.common.isDarkTheme qfluentwidgets.common.theme qfluentwidgets.common.isDarkThemeMode qfluentwidgets.common.setFont qfluentwidgets.common.getFont qfluentwidgets.common.setFontFamilies qfluentwidgets.common.fontFamilies qfluentwidgets.common.fontStyleSheet qfluentwidgets.common.getIconColor qfluentwidgets.common.drawSvgIcon qfluentwidgets.common.drawIcon qfluentwidgets.common.writeSvg qfluentwidgets.common.setStyleSheet qfluentwidgets.common.getStyleSheet qfluentwidgets.common.setTheme qfluentwidgets.common.themeColor qfluentwidgets.common.setThemeColor qfluentwidgets.common.applyThemeColor qfluentwidgets.common.toggleTheme qfluentwidgets.common.setCustomStyleSheet qfluentwidgets.common.renderQss .. autoapisummary:: qfluentwidgets.common.ALERT qfluentwidgets.common.qconfig qfluentwidgets.common.qrouter .. py:function:: exceptionHandler(*default) decorator for exception handling Parameters ---------- *default: the default value returned when an exception occurs .. py:data:: ALERT :value: Multiline-String .. raw:: html
Show Value .. code-block:: python """ 📢 Tips: QFluentWidgets Pro is now released. Click https://qfluentwidgets.com/pages/pro to learn more about it. """ .. raw:: html
.. py:class:: Theme Bases: :py:obj:`enum.Enum` Theme enumeration .. py:attribute:: LIGHT :value: 'Light' .. py:attribute:: DARK :value: 'Dark' .. py:attribute:: AUTO :value: 'Auto' .. py:class:: ConfigValidator Config validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: RangeValidator(min, max) Bases: :py:obj:`ConfigValidator` Range validator .. py:attribute:: min .. py:attribute:: max .. py:attribute:: range .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: OptionsValidator(options) Bases: :py:obj:`ConfigValidator` Options validator .. py:attribute:: options .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: BoolValidator Bases: :py:obj:`OptionsValidator` Boolean validator .. py:class:: FolderValidator Bases: :py:obj:`ConfigValidator` Folder validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: FolderListValidator Bases: :py:obj:`ConfigValidator` Folder list validator .. py:method:: validate(value) Verify whether the value is legal .. py:method:: correct(value: List[str]) correct illegal value .. py:class:: ColorValidator(default) Bases: :py:obj:`ConfigValidator` RGB color validator .. py:attribute:: default .. py:method:: validate(color) Verify whether the value is legal .. py:method:: correct(value) correct illegal value .. py:class:: ConfigSerializer Config serializer .. py:method:: serialize(value) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: EnumSerializer(enumClass) Bases: :py:obj:`ConfigSerializer` enumeration class serializer .. py:attribute:: enumClass .. py:method:: serialize(value) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: ColorSerializer Bases: :py:obj:`ConfigSerializer` QColor serializer .. py:method:: serialize(value: PyQt5.QtGui.QColor) serialize config value .. py:method:: deserialize(value) deserialize config from config file's value .. py:class:: ConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`PyQt5.QtCore.QObject` Config item .. py:attribute:: valueChanged .. py:attribute:: group .. py:attribute:: name .. py:attribute:: validator .. py:attribute:: serializer .. py:property:: value get the value of config item .. py:attribute:: restart :value: False .. py:attribute:: defaultValue .. py:property:: key get the config key separated by `.` .. py:method:: __str__() .. py:method:: serialize() .. py:method:: deserializeFrom(value) .. py:class:: RangeConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`ConfigItem` Config item of range .. py:property:: range get the available range of config .. py:method:: __str__() .. py:class:: OptionsConfigItem(group, name, default, validator=None, serializer=None, restart=False) Bases: :py:obj:`ConfigItem` Config item with options .. py:property:: options .. py:method:: __str__() .. py:class:: ColorConfigItem(group, name, default, restart=False) Bases: :py:obj:`ConfigItem` Color config item .. py:method:: __str__() .. py:class:: QConfig Bases: :py:obj:`PyQt5.QtCore.QObject` Config of app .. py:attribute:: appRestartSig .. py:attribute:: themeChanged .. py:attribute:: themeChangedFinished .. py:attribute:: themeColorChanged .. py:attribute:: themeMode .. py:attribute:: themeColor .. py:attribute:: fontFamilies .. py:attribute:: file .. py:method:: get(item) get the value of config item .. py:method:: set(item, value, save=True, copy=True) set the value of config item Parameters ---------- item: ConfigItem config item value: the new value of config item save: bool whether to save the change to config file copy: bool whether to deep copy the new value .. py:method:: toDict(serialize=True) convert config items to `dict` .. py:method:: save() save config .. py:method:: load(file=None, config=None) load config Parameters ---------- file: str or Path the path of json config file config: Config config object to be initialized .. py:property:: theme get theme mode, can be `Theme.Light` or `Theme.Dark` .. py:data:: qconfig .. py:function:: isDarkTheme() whether the theme is dark mode .. py:function:: theme() get theme mode .. py:function:: isDarkThemeMode(theme=Theme.AUTO) whether the theme is dark mode .. py:function:: setFont(widget: PyQt5.QtWidgets.QWidget, fontSize=14, weight=QFont.Normal) set the font of widget Parameters ---------- widget: QWidget the widget to set font fontSize: int font pixel size weight: `QFont.Weight` font weight .. py:function:: getFont(fontSize=14, weight=QFont.Normal) create font Parameters ---------- fontSize: int font pixel size weight: `QFont.Weight` font weight .. py:function:: setFontFamilies(families: List[str], save=False) set the font families used by all widgets Parameters ---------- families: List[str] font family names, the default value is `['Segoe UI', 'Microsoft YaHei', 'PingFang SC']` save: bool whether to save the change to config file .. py:function:: fontFamilies() -> List[str] Returns the font families used by all widgets .. py:function:: fontStyleSheet(font: PyQt5.QtGui.QFont) Returns the style sheet of font .. py:class:: TextWrap Text wrap .. py:attribute:: EAST_ASAIN_WIDTH_TABLE .. py:method:: get_width(char: str) -> int :classmethod: Returns the width of the char .. py:method:: get_text_width(text: str) -> int :classmethod: Returns the width of the text .. py:method:: get_char_type(char: str) -> CharType :classmethod: Returns the type of the char .. py:method:: process_text_whitespace(text: str) -> str :classmethod: Process whitespace and leading and trailing spaces in strings .. py:method:: split_long_token(token: str, width: int) -> List[str] :classmethod: Split long token into smaller chunks. .. py:method:: tokenizer(text: str) :classmethod: tokenize line .. py:method:: wrap(text: str, width: int, once: bool = True) -> Tuple[str, bool] :classmethod: Wrap according to string length Parameters ---------- text: str the text to be wrapped width: int the maximum length of a single line, the length of Chinese characters is 2 once: bool whether to wrap only once Returns ------- wrap_text: str text after auto word wrap process is_wrapped: bool whether a line break occurs in the text .. py:class:: Action(parent: PyQt5.QtCore.QObject = None, **kwargs) Bases: :py:obj:`PyQt5.QtWidgets.QAction` Fluent action Constructors ------------ * Action(`parent`: QWidget = None, `**kwargs`) * Action(`text`: str, `parent`: QWidget = None, `**kwargs`) * Action(`icon`: QIcon | FluentIconBase, `parent`: QWidget = None, `**kwargs`) .. py:attribute:: fluentIcon :value: None .. py:method:: icon() -> PyQt5.QtGui.QIcon .. py:method:: setIcon(icon: Union[FluentIconBase, PyQt5.QtGui.QIcon]) .. py:class:: Icon(fluentIcon: FluentIcon) Bases: :py:obj:`PyQt5.QtGui.QIcon` .. py:attribute:: fluentIcon .. py:function:: getIconColor(theme=Theme.AUTO, reverse=False) get the color of icon based on theme .. py:function:: drawSvgIcon(icon, painter, rect) draw svg icon Parameters ---------- icon: str | bytes | QByteArray the path or code of svg icon painter: QPainter painter rect: QRect | QRectF the rect to render icon .. py:class:: FluentIcon Bases: :py:obj:`FluentIconBase`, :py:obj:`enum.Enum` Fluent icon .. py:attribute:: UP :value: 'Up' .. py:attribute:: ADD :value: 'Add' .. py:attribute:: BUS :value: 'Bus' .. py:attribute:: CAR :value: 'Car' .. py:attribute:: CUT :value: 'Cut' .. py:attribute:: IOT :value: 'IOT' .. py:attribute:: PIN :value: 'Pin' .. py:attribute:: TAG :value: 'Tag' .. py:attribute:: VPN :value: 'VPN' .. py:attribute:: CAFE :value: 'Cafe' .. py:attribute:: CHAT :value: 'Chat' .. py:attribute:: COPY :value: 'Copy' .. py:attribute:: CODE :value: 'Code' .. py:attribute:: DOWN :value: 'Down' .. py:attribute:: EDIT :value: 'Edit' .. py:attribute:: FLAG :value: 'Flag' .. py:attribute:: FONT :value: 'Font' .. py:attribute:: GAME :value: 'Game' .. py:attribute:: HELP :value: 'Help' .. py:attribute:: HIDE :value: 'Hide' .. py:attribute:: HOME :value: 'Home' .. py:attribute:: INFO :value: 'Info' .. py:attribute:: LEAF :value: 'Leaf' .. py:attribute:: LINK :value: 'Link' .. py:attribute:: MAIL :value: 'Mail' .. py:attribute:: MENU :value: 'Menu' .. py:attribute:: MUTE :value: 'Mute' .. py:attribute:: MORE :value: 'More' .. py:attribute:: MOVE :value: 'Move' .. py:attribute:: PLAY :value: 'Play' .. py:attribute:: SAVE :value: 'Save' .. py:attribute:: SEND :value: 'Send' .. py:attribute:: SYNC :value: 'Sync' .. py:attribute:: UNIT :value: 'Unit' .. py:attribute:: VIEW :value: 'View' .. py:attribute:: WIFI :value: 'Wifi' .. py:attribute:: ZOOM :value: 'Zoom' .. py:attribute:: ALBUM :value: 'Album' .. py:attribute:: BRUSH :value: 'Brush' .. py:attribute:: BROOM :value: 'Broom' .. py:attribute:: CLOSE :value: 'Close' .. py:attribute:: CLOUD :value: 'Cloud' .. py:attribute:: EMBED :value: 'Embed' .. py:attribute:: GLOBE :value: 'Globe' .. py:attribute:: HEART :value: 'Heart' .. py:attribute:: LABEL :value: 'Label' .. py:attribute:: MEDIA :value: 'Media' .. py:attribute:: MOVIE :value: 'Movie' .. py:attribute:: MUSIC :value: 'Music' .. py:attribute:: ROBOT :value: 'Robot' .. py:attribute:: PAUSE :value: 'Pause' .. py:attribute:: PASTE :value: 'Paste' .. py:attribute:: PHOTO :value: 'Photo' .. py:attribute:: PHONE :value: 'Phone' .. py:attribute:: PRINT :value: 'Print' .. py:attribute:: SHARE :value: 'Share' .. py:attribute:: TILES :value: 'Tiles' .. py:attribute:: UNPIN :value: 'Unpin' .. py:attribute:: VIDEO :value: 'Video' .. py:attribute:: TRAIN :value: 'Train' .. py:attribute:: ADD_TO :value: 'AddTo' .. py:attribute:: ACCEPT :value: 'Accept' .. py:attribute:: CAMERA :value: 'Camera' .. py:attribute:: CANCEL :value: 'Cancel' .. py:attribute:: DELETE :value: 'Delete' .. py:attribute:: FOLDER :value: 'Folder' .. py:attribute:: FILTER :value: 'Filter' .. py:attribute:: MARKET :value: 'Market' .. py:attribute:: SCROLL :value: 'Scroll' .. py:attribute:: LAYOUT :value: 'Layout' .. py:attribute:: GITHUB :value: 'GitHub' .. py:attribute:: UPDATE :value: 'Update' .. py:attribute:: REMOVE :value: 'Remove' .. py:attribute:: RETURN :value: 'Return' .. py:attribute:: PEOPLE :value: 'People' .. py:attribute:: QRCODE :value: 'QRCode' .. py:attribute:: RINGER :value: 'Ringer' .. py:attribute:: ROTATE :value: 'Rotate' .. py:attribute:: SEARCH :value: 'Search' .. py:attribute:: VOLUME :value: 'Volume' .. py:attribute:: FRIGID :value: 'Frigid' .. py:attribute:: SAVE_AS :value: 'SaveAs' .. py:attribute:: ZOOM_IN :value: 'ZoomIn' .. py:attribute:: CONNECT :value: 'Connect' .. py:attribute:: HISTORY :value: 'History' .. py:attribute:: SETTING :value: 'Setting' .. py:attribute:: PALETTE :value: 'Palette' .. py:attribute:: MESSAGE :value: 'Message' .. py:attribute:: FIT_PAGE :value: 'FitPage' .. py:attribute:: ZOOM_OUT :value: 'ZoomOut' .. py:attribute:: AIRPLANE :value: 'Airplane' .. py:attribute:: ASTERISK :value: 'Asterisk' .. py:attribute:: CALORIES :value: 'Calories' .. py:attribute:: CALENDAR :value: 'Calendar' .. py:attribute:: FEEDBACK :value: 'Feedback' .. py:attribute:: LIBRARY :value: 'BookShelf' .. py:attribute:: MINIMIZE :value: 'Minimize' .. py:attribute:: CHECKBOX :value: 'CheckBox' .. py:attribute:: DOCUMENT :value: 'Document' .. py:attribute:: LANGUAGE :value: 'Language' .. py:attribute:: DOWNLOAD :value: 'Download' .. py:attribute:: QUESTION :value: 'Question' .. py:attribute:: SPEAKERS :value: 'Speakers' .. py:attribute:: DATE_TIME :value: 'DateTime' .. py:attribute:: FONT_SIZE :value: 'FontSize' .. py:attribute:: HOME_FILL :value: 'HomeFill' .. py:attribute:: PAGE_LEFT :value: 'PageLeft' .. py:attribute:: SAVE_COPY :value: 'SaveCopy' .. py:attribute:: SEND_FILL :value: 'SendFill' .. py:attribute:: SKIP_BACK :value: 'SkipBack' .. py:attribute:: SPEED_OFF :value: 'SpeedOff' .. py:attribute:: ALIGNMENT :value: 'Alignment' .. py:attribute:: BLUETOOTH :value: 'Bluetooth' .. py:attribute:: COMPLETED :value: 'Completed' .. py:attribute:: CONSTRACT :value: 'Constract' .. py:attribute:: HEADPHONE :value: 'Headphone' .. py:attribute:: MEGAPHONE :value: 'Megaphone' .. py:attribute:: PROJECTOR :value: 'Projector' .. py:attribute:: EDUCATION :value: 'Education' .. py:attribute:: LEFT_ARROW :value: 'LeftArrow' .. py:attribute:: ERASE_TOOL :value: 'EraseTool' .. py:attribute:: PAGE_RIGHT :value: 'PageRight' .. py:attribute:: PLAY_SOLID :value: 'PlaySolid' .. py:attribute:: BOOK_SHELF :value: 'BookShelf' .. py:attribute:: HIGHTLIGHT :value: 'Highlight' .. py:attribute:: FOLDER_ADD :value: 'FolderAdd' .. py:attribute:: PAUSE_BOLD :value: 'PauseBold' .. py:attribute:: PENCIL_INK :value: 'PencilInk' .. py:attribute:: PIE_SINGLE :value: 'PieSingle' .. py:attribute:: QUICK_NOTE :value: 'QuickNote' .. py:attribute:: SPEED_HIGH :value: 'SpeedHigh' .. py:attribute:: STOP_WATCH :value: 'StopWatch' .. py:attribute:: ZIP_FOLDER :value: 'ZipFolder' .. py:attribute:: BASKETBALL :value: 'Basketball' .. py:attribute:: BRIGHTNESS :value: 'Brightness' .. py:attribute:: DICTIONARY :value: 'Dictionary' .. py:attribute:: MICROPHONE :value: 'Microphone' .. py:attribute:: ARROW_DOWN :value: 'ChevronDown' .. py:attribute:: FULL_SCREEN :value: 'FullScreen' .. py:attribute:: MIX_VOLUMES :value: 'MixVolumes' .. py:attribute:: REMOVE_FROM :value: 'RemoveFrom' .. py:attribute:: RIGHT_ARROW :value: 'RightArrow' .. py:attribute:: QUIET_HOURS :value: 'QuietHours' .. py:attribute:: FINGERPRINT :value: 'Fingerprint' .. py:attribute:: APPLICATION :value: 'Application' .. py:attribute:: CERTIFICATE :value: 'Certificate' .. py:attribute:: TRANSPARENT :value: 'Transparent' .. py:attribute:: IMAGE_EXPORT :value: 'ImageExport' .. py:attribute:: SPEED_MEDIUM :value: 'SpeedMedium' .. py:attribute:: LIBRARY_FILL :value: 'LibraryFill' .. py:attribute:: MUSIC_FOLDER :value: 'MusicFolder' .. py:attribute:: POWER_BUTTON :value: 'PowerButton' .. py:attribute:: SKIP_FORWARD :value: 'SkipForward' .. py:attribute:: CARE_UP_SOLID :value: 'CareUpSolid' .. py:attribute:: ACCEPT_MEDIUM :value: 'AcceptMedium' .. py:attribute:: CANCEL_MEDIUM :value: 'CancelMedium' .. py:attribute:: CHEVRON_RIGHT :value: 'ChevronRight' .. py:attribute:: CLIPPING_TOOL :value: 'ClippingTool' .. py:attribute:: SEARCH_MIRROR :value: 'SearchMirror' .. py:attribute:: SHOPPING_CART :value: 'ShoppingCart' .. py:attribute:: FONT_INCREASE :value: 'FontIncrease' .. py:attribute:: BACK_TO_WINDOW :value: 'BackToWindow' .. py:attribute:: COMMAND_PROMPT :value: 'CommandPrompt' .. py:attribute:: CLOUD_DOWNLOAD :value: 'CloudDownload' .. py:attribute:: DICTIONARY_ADD :value: 'DictionaryAdd' .. py:attribute:: CARE_DOWN_SOLID :value: 'CareDownSolid' .. py:attribute:: CARE_LEFT_SOLID :value: 'CareLeftSolid' .. py:attribute:: CLEAR_SELECTION :value: 'ClearSelection' .. py:attribute:: DEVELOPER_TOOLS :value: 'DeveloperTools' .. py:attribute:: BACKGROUND_FILL :value: 'BackgroundColor' .. py:attribute:: CARE_RIGHT_SOLID :value: 'CareRightSolid' .. py:attribute:: CHEVRON_DOWN_MED :value: 'ChevronDownMed' .. py:attribute:: CHEVRON_RIGHT_MED :value: 'ChevronRightMed' .. py:attribute:: EMOJI_TAB_SYMBOLS :value: 'EmojiTabSymbols' .. py:attribute:: EXPRESSIVE_INPUT_ENTRY :value: 'ExpressiveInputEntry' .. py:method:: path(theme=Theme.AUTO) get the path of icon Parameters ---------- theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `config.theme` .. py:function:: drawIcon(icon, painter, rect, state=QIcon.Off, **attributes) draw icon Parameters ---------- icon: str | QIcon | FluentIconBaseBase the icon to be drawn painter: QPainter painter rect: QRect | QRectF the rect to render icon **attribute: the attribute of svg icon .. py:class:: FluentIconBase Fluent icon base class .. py:method:: path(theme=Theme.AUTO) -> str :abstractmethod: get the path of icon Parameters ---------- theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `config.theme` .. py:method:: icon(theme=Theme.AUTO, color: PyQt5.QtGui.QColor = None) -> PyQt5.QtGui.QIcon create a fluent icon Parameters ---------- theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `qconfig.theme` color: QColor | Qt.GlobalColor | str icon color, only applicable to svg icon .. py:method:: colored(lightColor: PyQt5.QtGui.QColor, darkColor: PyQt5.QtGui.QColor) -> ColoredFluentIcon create a colored fluent icon Parameters ---------- lightColor: str | QColor | Qt.GlobalColor icon color in light mode darkColor: str | QColor | Qt.GlobalColor icon color in dark mode .. py:method:: qicon(reverse=False) -> PyQt5.QtGui.QIcon convert to QIcon, the theme of icon will be updated synchronously with app Parameters ---------- reverse: bool whether to reverse the theme of icon .. py:method:: render(painter, rect, theme=Theme.AUTO, indexes=None, **attributes) draw svg icon Parameters ---------- painter: QPainter painter rect: QRect | QRectF the rect to render icon theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `config.theme` indexes: List[int] the svg path to be modified **attributes: the attributes of modified path .. py:function:: writeSvg(iconPath: str, indexes=None, **attributes) write svg with specified attributes Parameters ---------- iconPath: str svg icon path indexes: List[int] the path to be filled **attributes: the attributes of path Returns ------- svg: str svg code .. py:class:: FluentFontIconBase(char: str) Bases: :py:obj:`FluentIconBase` Fluent font icon base class .. py:attribute:: fontId :value: None .. py:attribute:: fontFamily :value: None .. py:attribute:: char .. py:attribute:: lightColor .. py:attribute:: darkColor .. py:attribute:: isBold :value: False .. py:method:: fromName(name: str) :classmethod: .. py:method:: bold() .. py:method:: icon(theme=Theme.AUTO, color: PyQt5.QtGui.QColor = None) -> PyQt5.QtGui.QIcon create a fluent icon Parameters ---------- theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `qconfig.theme` color: QColor | Qt.GlobalColor | str icon color, only applicable to svg icon .. py:method:: colored(lightColor, darkColor) create a colored fluent icon Parameters ---------- lightColor: str | QColor | Qt.GlobalColor icon color in light mode darkColor: str | QColor | Qt.GlobalColor icon color in dark mode .. py:method:: render(painter: PyQt5.QtGui.QPainter, rect, theme=Theme.AUTO, indexes=None, **attributes) draw svg icon Parameters ---------- painter: QPainter painter rect: QRect | QRectF the rect to render icon theme: Theme the theme of icon * `Theme.Light`: black icon * `Theme.DARK`: white icon * `Theme.AUTO`: icon color depends on `config.theme` indexes: List[int] the svg path to be modified **attributes: the attributes of modified path .. py:method:: iconNameMapPath() -> str .. py:method:: loadFont() Load icon font .. py:method:: loadIconNames() Load icon name map .. 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:: 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:: 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: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 .. 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: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:: 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:: 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:: 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: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: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: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:: 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:: SmoothScroll(widget: PyQt5.QtWidgets.QScrollArea, orient=Qt.Vertical, dynamicEngineEnabled=True) Scroll smoothly .. py:attribute:: widget .. py:attribute:: orient .. py:attribute:: dynamicEngineEnabled :value: True .. py:attribute:: widthThreshold :value: 2560 .. py:attribute:: smoothMode .. py:attribute:: fixedStepScrollEngine .. py:attribute:: adaptiveScrollEngine .. py:method:: setDynamicEngineEnabled(isEnabled: bool) set whether to use dynamic engine .. py:method:: setSmoothMode(smoothMode) set smooth mode .. py:method:: wheelEvent(e) .. py:class:: SmoothMode Bases: :py:obj:`enum.Enum` Smooth mode .. py:attribute:: NO_SMOOTH :value: 0 .. py:attribute:: CONSTANT :value: 1 .. py:attribute:: LINEAR :value: 2 .. py:attribute:: QUADRATI :value: 3 .. py:attribute:: COSINE :value: 4 .. py:class:: FluentTranslator(locale: PyQt5.QtCore.QLocale = None, parent=None) Bases: :py:obj:`PyQt5.QtCore.QTranslator` Translator of fluent widgets .. py:method:: load(locale: PyQt5.QtCore.QLocale) load translation file .. py:data:: qrouter .. py:class:: Router(parent=None) Bases: :py:obj:`PyQt5.QtCore.QObject` Router .. py:attribute:: emptyChanged .. py:attribute:: history :type: List[RouteItem] :value: [] .. py:attribute:: stackHistories :type: Dict[PyQt5.QtWidgets.QStackedWidget, StackedHistory] .. py:method:: setDefaultRouteKey(stacked: PyQt5.QtWidgets.QStackedWidget, routeKey: str) set the default route key of stacked widget .. py:method:: push(stacked: PyQt5.QtWidgets.QStackedWidget, routeKey: str) push history Parameters ---------- stacked: QStackedWidget stacked widget routeKey: str route key of sub insterface, it should be the object name of sub interface .. py:method:: pop() pop history .. py:method:: remove(routeKey: str) remove history .. py:class:: FluentThemeColor Bases: :py:obj:`enum.Enum` Fluent theme color Refer to: https://www.figma.com/file/iM7EPX8Jn37zjeSezb43cF .. py:attribute:: YELLOW_GOLD :value: '#FFB900' .. py:attribute:: GOLD :value: '#FF8C00' .. py:attribute:: ORANGE_BRIGHT :value: '#F7630C' .. py:attribute:: ORANGE_DARK :value: '#CA5010' .. py:attribute:: RUST :value: '#DA3B01' .. py:attribute:: PALE_RUST :value: '#EF6950' .. py:attribute:: BRICK_RED :value: '#D13438' .. py:attribute:: MOD_RED :value: '#FF4343' .. py:attribute:: PALE_RED :value: '#E74856' .. py:attribute:: RED :value: '#E81123' .. py:attribute:: ROSE_BRIGHT :value: '#EA005E' .. py:attribute:: ROSE :value: '#C30052' .. py:attribute:: PLUM_LIGHT :value: '#E3008C' .. py:attribute:: PLUM :value: '#BF0077' .. py:attribute:: ORCHID_LIGHT :value: '#BF0077' .. py:attribute:: ORCHID :value: '#9A0089' .. py:attribute:: DEFAULT_BLUE :value: '#0078D7' .. py:attribute:: NAVY_BLUE :value: '#0063B1' .. py:attribute:: PURPLE_SHADOW :value: '#8E8CD8' .. py:attribute:: PURPLE_SHADOW_DARK :value: '#6B69D6' .. py:attribute:: IRIS_PASTEL :value: '#8764B8' .. py:attribute:: IRIS_SPRING :value: '#744DA9' .. py:attribute:: VIOLET_RED_LIGHT :value: '#B146C2' .. py:attribute:: VIOLET_RED :value: '#881798' .. py:attribute:: COOL_BLUE_BRIGHT :value: '#0099BC' .. py:attribute:: COOL_BLUR :value: '#2D7D9A' .. py:attribute:: SEAFOAM :value: '#00B7C3' .. py:attribute:: SEAFOAM_TEAL :value: '#038387' .. py:attribute:: MINT_LIGHT :value: '#00B294' .. py:attribute:: MINT_DARK :value: '#018574' .. py:attribute:: TURF_GREEN :value: '#00CC6A' .. py:attribute:: SPORT_GREEN :value: '#10893E' .. py:attribute:: GRAY :value: '#7A7574' .. py:attribute:: GRAY_BROWN :value: '#5D5A58' .. py:attribute:: STEAL_BLUE :value: '#68768A' .. py:attribute:: METAL_BLUE :value: '#515C6B' .. py:attribute:: PALE_MOSS :value: '#567C73' .. py:attribute:: MOSS :value: '#486860' .. py:attribute:: MEADOW_GREEN :value: '#498205' .. py:attribute:: GREEN :value: '#107C10' .. py:attribute:: OVERCAST :value: '#767676' .. py:attribute:: STORM :value: '#4C4A48' .. py:attribute:: BLUE_GRAY :value: '#69797E' .. py:attribute:: GRAY_DARK :value: '#4A5459' .. py:attribute:: LIDDY_GREEN :value: '#647C64' .. py:attribute:: SAGE :value: '#525E54' .. py:attribute:: CAMOUFLAGE_DESERT :value: '#847545' .. py:attribute:: CAMOUFLAGE :value: '#7E735F' .. py:method:: color() .. py:class:: FluentSystemColor Bases: :py:obj:`enum.Enum` Generic enumeration. Derive from this class to define new enumerations. .. py:attribute:: SUCCESS_FOREGROUND :value: ('#0f7b0f', '#6ccb5f') .. py:attribute:: CAUTION_FOREGROUND :value: ('#9d5d00', '#fce100') .. py:attribute:: CRITICAL_FOREGROUND :value: ('#c42b1c', '#ff99a4') .. py:attribute:: SUCCESS_BACKGROUND :value: ('#dff6dd', '#393d1b') .. py:attribute:: CAUTION_BACKGROUND :value: ('#fff4ce', '#433519') .. py:attribute:: CRITICAL_BACKGROUND :value: ('#fde7e9', '#442726') .. py:method:: color(theme=Theme.AUTO) -> PyQt5.QtGui.QColor .. py:class:: SystemThemeListener(parent=None) Bases: :py:obj:`PyQt5.QtCore.QThread` System theme listener .. py:attribute:: systemThemeChanged .. py:method:: run()