QLedWidget#

class QInstrument.widgets.QLedWidget.QLedWidget(*args, color=None, state=None, blink=None, interval=None, **kwargs)[source]#

Bases: QWidget

LED indicator widget drawn with QPainter.

Renders a colored LED that can be on, off, or blinking.

Properties#

blinkbool

True: LED alternates between ON and OFF states at interval ms per state. False: LED returns to its saved state and stops blinking.

colorQLedWidget.Color

LED color. One of RED, AMBER, GREEN, BLUE, VIOLET, WHITE.

intervalint [ms]

Duration of each ON/OFF phase during blinking. Default: 400.

stateQLedWidget.State

ON: LED is bright. OFF: LED is dark.

class Color(*values)[source]#

Bases: Enum

RED = 1#
AMBER = 2#
GREEN = 3#
BLUE = 4#
VIOLET = 5#
WHITE = 6#
class State(*values)[source]#

Bases: Enum

OFF = 0#
ON = 1#
RED = 1#
AMBER = 2#
GREEN = 3#
BLUE = 4#
VIOLET = 5#
WHITE = 6#
OFF = 0#
ON = 1#
hexcodes = {Color.AMBER: {State.OFF: ('aa4400', 'ad892c'), State.ON: ('d45500', 'ffd42a')}, Color.BLUE: {State.OFF: ('102151', '0a163c'), State.ON: ('082686', '0342eb')}, Color.GREEN: {State.OFF: ('001c00', '008200'), State.ON: ('009400', '00d700')}, Color.RED: {State.OFF: ('3f0000', 'a00000'), State.ON: ('af0000', 'ff0f0f')}, Color.VIOLET: {State.OFF: ('45098f', '471b7d'), State.ON: ('5a00cc', 'a65fff')}, Color.WHITE: {State.OFF: ('505055', 'a0a0aa'), State.ON: ('d0d0dd', 'f0f0ff')}}#
sizeHint()[source]#
Return type:

QSize

property interval: int#
value()[source]#

Return the LED state as a boolean.

Return type:

bool

Returns:

boolTrue when the LED is ON False when OFF.

setValue(value)[source]#

Set the LED state from a boolean value.

Parameters:

value (bool) – True to turn the LED ON; False for OFF.

Return type:

None

flipState()#

Toggle the LED between ON and OFF states.

Return type:

None

changeEvent(event)[source]#

Gray out the LED when disabled; restore color when re-enabled.

When the widget (or any ancestor) is disabled, the LED switches to WHITE/OFF so it looks unpowered, consistent with the rest of the disabled instrument UI. The original color, state, and blink are saved and restored when the widget is re-enabled.

Return type:

None

paintEvent(event)[source]#
Return type:

None