8.6.8.2.6. pymodaq_gui.utils.widgets.multistate_led module

class pymodaq_gui.utils.widgets.multistate_led.LedState(*values)[source]

Bases: StrEnum

Default two-state set for MultistateLED — visually matches QLED.

Members behave as plain str (e.g. LedState.TRUE == 'true'), so existing code passing 'true' / 'false' string literals keeps working unchanged.

FALSE = 'False'
TRUE = 'True'
class pymodaq_gui.utils.widgets.multistate_led.MultistateLED(parent=None, states=None, readonly=True, clickable_cycle=True, size=20, shape='circle', gradient='radial')[source]

Bases: QWidget

A painted LED indicator that can represent any number of named states.

Each state is a (name, color) pair supplied at construction time. The widget emits state_changed with the state name whenever the active state changes.

Parameters:
  • parent (QWidget, optional)

  • states (list of (str, str | QColor), optional) – Ordered [(name, color), ...] pairs. name can be a plain string or a StrEnum member (e.g. LedState or Status) — both compare equal to their string value, so mixing the two is safe. color can be a hex string ('#rrggbb'), an SVG color name, or a QColor instance (e.g. from StatusPalette). Defaults to DEFAULT_STATES (a two-state red/green set keyed on LedState).

  • readonly (bool) – When True (default) clicking has no effect. Sets self.clickable to not readonly — assign w.clickable directly to change at runtime (same pattern as QLED).

  • clickable_cycle (bool) – When True (default) each click advances to the next state in order, wrapping around. When False, clicking only toggles between the first and last state.

  • size (int) – Diameter / side length of the shape in pixels (default 20).

  • shape (str) – Visual shape: one of 'circle', 'square', 'triangle', 'diamond', 'rectangle'. Defaults to 'circle'.

  • gradient (str) – Fill style passed to make_brush(). One of 'flat' (default), 'radial', 'linear', 'glow'.

Methods

cycle()

Advance to the next state programmatically (ignores clickable).

get_state()

Return the current state name.

set_state(name)

Set the active state by name.

set_states(states)

Replace the full state list.

state_names()

Return the ordered list of state names.

changeEvent

mouseReleaseEvent

paintEvent

set_gradient

set_shape

set_size

sizeHint

state_changed

changeEvent(event)[source]
cycle()[source]

Advance to the next state programmatically (ignores clickable).

get_state()[source]

Return the current state name.

Return type:

str

mouseReleaseEvent(event)[source]
paintEvent(event)[source]
set_gradient(gradient)[source]
set_shape(shape)[source]
set_size(size)[source]
set_state(name)[source]

Set the active state by name. Emits state_changed if changed.

set_states(states)[source]

Replace the full state list. Current state is reset to index 0.

sizeHint()[source]
state_names()[source]

Return the ordered list of state names.

Return type:

list[str]

state_changed
staticMetaObject = PySide6.QtCore.QMetaObject("MultistateLED" inherits "QWidget": Methods:   #33 type=Signal, signature=state_changed(QString), parameters=QString )
pymodaq_gui.utils.widgets.multistate_led.main()[source]