switch_button ============= .. py:module:: qfluentwidgets.components.widgets.switch_button Module Contents --------------- .. autoapisummary:: qfluentwidgets.components.widgets.switch_button.Indicator qfluentwidgets.components.widgets.switch_button.IndicatorPosition qfluentwidgets.components.widgets.switch_button.SwitchButton .. py:class:: Indicator(parent) Bases: :py:obj:`qfluentwidgets.components.widgets.button.ToolButton` Indicator of switch button .. py:attribute:: checkedChanged .. py:attribute:: lightCheckedColor .. py:attribute:: darkCheckedColor .. py:attribute:: slideAni .. py:method:: mouseReleaseEvent(e) toggle checked state when mouse release .. py:method:: toggle() .. py:method:: setDown(isDown: bool) .. py:method:: setHover(isHover: bool) .. py:method:: setCheckedColor(light, dark) .. py:method:: paintEvent(e) paint indicator .. py:method:: getSliderX() .. py:method:: setSliderX(x) .. py:attribute:: sliderX .. py:class:: IndicatorPosition Bases: :py:obj:`enum.Enum` Indicator position .. py:attribute:: LEFT :value: 0 .. py:attribute:: RIGHT :value: 1 .. py:class:: SwitchButton(parent: PyQt5.QtWidgets.QWidget = None, indicatorPos=IndicatorPosition.LEFT) Bases: :py:obj:`PyQt5.QtWidgets.QWidget` Switch button class Constructors ------------ * SwitchButton(`parent`: QWidget = None) * SwitchButton(`text`: str = "Off", `parent`: QWidget = None, `indicatorPos`=IndicatorPosition.LEFT) .. py:attribute:: checkedChanged .. py:attribute:: lightTextColor .. py:attribute:: darkTextColor .. py:attribute:: indicatorPos .. py:attribute:: hBox .. py:attribute:: indicator .. py:attribute:: label .. py:method:: eventFilter(obj, e: PyQt5.QtCore.QEvent) .. py:method:: isChecked() .. py:method:: setChecked(isChecked) set checked state .. py:method:: setTextColor(light, dark) set the color of text Parameters ---------- light, dark: str | QColor | Qt.GlobalColor text color in light/dark theme mode .. py:method:: setCheckedIndicatorColor(light, dark) set the color of indicator in checked status Parameters ---------- light, dark: str | QColor | Qt.GlobalColor border color in light/dark theme mode .. py:method:: toggleChecked() toggle checked state .. py:method:: getText() .. py:method:: setText(text) .. py:method:: getSpacing() .. py:method:: setSpacing(spacing) .. py:method:: getOnText() .. py:method:: setOnText(text) .. py:method:: getOffText() .. py:method:: setOffText(text) .. py:attribute:: spacing .. py:attribute:: checked .. py:attribute:: text .. py:attribute:: onText .. py:attribute:: offText