msl.qt.widgets.led module

An LED widget.

class msl.qt.widgets.led.LED(*, parent=None, shape=<Shapes.Circle: 0>, on_color='#0F6900', off_color='grey', clickable=False, tooltip=None)[source]

Bases: QWidget

An LED widget, led_widget

This class is based off of the QLed project.

Parameters:
  • parent (QtWidgets.QWidget) – The parent widget.
  • shape (int, str or Shapes) – The shape to draw the LED. If a str then the name of one of the Shapes, e.g. 0, 'circle' and Shapes.Circle are equivalent.
  • on_color – The color when the LED is on. See to_qcolor() for details about the different data types that are supported.
  • off_color – The color when the LED is off. See to_qcolor() for details about the different data types that are supported.
  • clickable (bool) – Whether the state of the LED can be changed by clicking on it.
  • tooltip (str, optional) – The tooltip to use for the LED.

Example

To view an example with the LED run:

>>> from msl.examples.qt import led
>>> led.show()  
Circle = 0
Rounded = 1
Square = 2
Triangle = 3
clickable()[source]

Get if the on/off state of the LED can be changed by clicking on it.

Returns:bool – Whether the state of the LED can be changed by clicking on it.
clicked = None

Emitted when the LED is clicked (even if it is not clickable).

is_on

Whether the LED is on or off.

Type:bool
off_color()[source]

Get the color of the LED when it is off.

Returns:QtGui.QColor – The off color.
on_color()[source]

Get the color of the LED when it is on.

Returns:QtGui.QColor – The on color.
set_clickable(clickable)[source]

Set if the on/off state of the LED can be changed by clicking on it.

Parameters:clickable (bool) – Whether the state of the LED can be changed by clicking on it.
set_off_color(color)[source]

Set the color of the LED when it is off.

Parameters:color – The color when the LED is off. See to_qcolor() for details about the different data types that are supported.
set_on_color(color)[source]

Set the color of the LED when it is on.

Parameters:color – The color when the LED is on. See to_qcolor() for details about the different data types that are supported.
set_shape(shape)[source]

Set the shape of the LED.

Parameters:shape (int, str or Shapes) – The shape to draw the LED. If a str then the name of one of the Shapes, e.g. 0, 'circle' and Shapes.Circle are equivalent.
shape()[source]

Get the shape of the LED.

Returns:Shapes – The shape of the LED.
toggle()[source]

Toggle the on/off state of the LED.

toggled = None

Emitted when the LED turns on \(\rightarrow\) off or off \(\rightarrow\) on.

turn_off()[source]

Turn the LED off.

turn_on()[source]

Turn the LED on.

class msl.qt.widgets.led.Shapes[source]

Bases: enum.IntEnum

Shapes that are available to draw the LED.

Circle = 0
Rounded = 1
Square = 2
Triangle = 3
msl.qt.widgets.led.Signal(*args, **kwargs)