← Back to widgets
ToggleSwitch¶
Source: Distributed_Design_Optimizer/postprocess/widgets/ToggleSwitch.py
Custom toggle switch widget — a modern on/off slider control.
Classes¶
_SwitchTrack¶
Inherits from:
QWidgetThe sliding toggle track (no label).
Methods¶
init(self, parent: QWidget | None) → None
Initialize the switch track widget.
Args:
parent: Optional parent widget.
isChecked(self) → bool
Return whether the switch is in the on state.
Returns:
True if the switch is on, False otherwise.
setChecked(self, checked: bool) → None
Set the checked state and animate the thumb.
Args:
checked:
Trueto turn on,Falseto turn off.
mousePressEvent(self, event) → None
Toggle the switch state on mouse press.
Args:
event: The mouse press event.
changeEvent(self, event) → None
Repaint when the enabled state changes.
Args:
event: The change event triggered by Qt.
paintEvent(self, event) → None
Draw the track and sliding thumb.
Args:
event: The paint event triggered by Qt.
ToggleSwitch¶
Inherits from:
QWidgetA labelled toggle switch: [label] [=====O].
Methods¶
init(self, label: str, parent: QWidget | None) → None
Initialize the labelled toggle switch.
Args:
label: Text label displayed beside the switch.
parent: Optional parent widget.
isChecked(self) → bool
Return whether the toggle is checked.
Returns:
True if the toggle is on, False otherwise.
setChecked(self, checked: bool) → None
Set the toggle checked state.
Args:
checked:
Trueto turn on,Falseto turn off.
setToolTip(self, tip: str) → None
Apply the tooltip to the label and switch track.
Args:
tip: Tooltip text.