switch.switch

This module provides a custom PySide6 QWidget implementation for a switch-style button with text display. The Switch class allows users to cycle through predefined values by clicking a button, emitting a valueChanged signal when toggled.

Classes:

  • Switch: A custom widget that displays a label and a button, cycling through provided values when clicked.

Usage Example:

>>> switch = Switch("Mode", ["Off", "On"])
>>> switch.valueChanged.connect(lambda index: print(f"Switch changed to: {index}"))
>>> switch.setValue(1)  # Sets the switch to "On"

Classes

Switch

Custom switch widget with text display

Module Contents

class switch.switch.Switch(label: str, values: list[str], parent: PySide6.QtWidgets.QWidget | None = None, tooltip: str = '')[source]

Bases: PySide6.QtWidgets.QWidget

Custom switch widget with text display

valueChanged[source]
values[source]
current_index = 0[source]
label[source]
button[source]
_on_clicked() None[source]

Handle button clicks

setValue(value: int) None[source]

Set current value

setLabel(text: str) None[source]

Set label text

value() int[source]

Get current value