PyDMByteIndicator
- class pydm.widgets.byte.PyDMByteIndicator(parent: Optional[QWidget] = None, init_channel=None)[source]
Bases:
QWidget,PyDMWidgetWidget for graphical representation of bits from an integer number with support for Channels and more from PyDM, including blinking functionality.
- Parameters:
parent (QWidget) – The parent widget for the Label
init_channel (str, optional) – The channel to be used by the widget.
- alarm_severity_changed(new_alarm_severity: int) None[source]
Callback invoked when the Channel alarm severity is changed.
- Parameters:
new_alarm_severity (int) – The new severity where 0 = NO_ALARM, 1 = MINOR, 2 = MAJOR and 3 = INVALID
- connection_changed(connected: bool) None[source]
Callback invoked when the connection state of the Channel is changed. This callback acts on the connection state to enable/disable the widget and also trigger the change on alarm severity to ALARM_DISCONNECTED.
- Parameters:
connected (bool) – When this value is False the channel is disconnected, True otherwise.
- init_for_designer() None[source]
Method called after the constructor to tweak configurations for when using the widget with the Qt Designer
- paintEvent(_) None[source]
Paint events are sent to widgets that need to update themselves, for instance when part of a widget is exposed because a covering widget was moved.
At PyDMDrawing this method handles the alarm painting with parameters from the stylesheet, configures the brush, pen and calls
`draw_item`so the specifics can be performed for each of the drawing classes.- Parameters:
event (QPaintEvent) –
- prop_type
alias of
Orientation
- readBigEndian() bool[source]
Whether the most significant bit is at the start or end of the widget.
- Return type:
bool
- readLabelPosition() TabPosition[source]
The side of the widget to display labels on.
- Return type:
int
- readOrientation() int | PyQt5.QtCore.Qt.Orientation[source]
Whether to lay out the bit indicators vertically or horizontally.
- Return type:
int
- readShowLabels() bool[source]
Whether or not to show labels next to each bit indicator.
- Return type:
bool
- readToggleMode() bool[source]
Get the toggle mode state.
- Returns:
True if toggle mode is enabled, False otherwise.
- Return type:
bool
- rebuild_layout() None[source]
Method to reorganize the top-level widget and its contents according to the layout property values.
- setBigEndian(is_big_endian: bool) None[source]
Whether the most significant bit is at the start or end of the widget.
- Parameters:
is_big_endian (bool) – If True, the Big Endian will be used, Little Endian otherwise
- setBlinkColor1(new_color: QColor) None[source]
The first color for blinking effect.
- Parameters:
new_color (QColor) –
- setBlinkColor2(new_color: QColor) None[source]
The second color for blinking effect.
- Parameters:
new_color (QColor) –
- setBlinkInterval(interval: int) None[source]
The interval for blinking in milliseconds.
- Parameters:
interval (int) –
- setBlinkOnChange(blink: bool) None[source]
Whether to enable blinking on value change.
- Parameters:
blink (bool) – If True, enables blinking on value change
- setCircles(draw_circles: bool) None[source]
Draw indicators as circles, rather than rectangles.
- Parameters:
draw_circles (bool) – If True, bits will be represented as circles
- setLabelPosition(new_pos: TabPosition) None[source]
The side of the widget to display labels on.
- Parameters:
new_pos (QTabWidget.TabPosition, int) –
- setNumBits(new_num_bits: int) None[source]
Number of bits to interpret.
- Parameters:
new_num_bits (int) –
- setOffColor(new_color: QColor) None[source]
The color for a bit in the ‘off’ state.
- Parameters:
new_color (QColor) –
- setOnColor(new_color: QColor) None[source]
The color for a bit in the ‘on’ state.
- Parameters:
new_color (QColor) –
- setOrientation(new_orientation: Orientation) None[source]
Whether to lay out the bit indicators vertically or horizontally.
- Parameters:
new_orientation (Qt.Orientation, int) –
- setShowLabels(show: bool) None[source]
Whether or not to show labels next to each bit indicator.
- Parameters:
show (bool) – If True the widget will show a label next to the bit indicator
Note
See QWidget Documentation for all inherited properties and methods.
# Remove the separate PyDMBlinkByteIndicator class since its functionality is now integrated into PyDMByteIndicator # PyDMBlinkByteIndicator is no longer needed
Core Blinking Mechanism - Added QTimer for timed color switching - _toggle_blink_color() method alternates between two blink colors - _start_blinking() and _stop_blinking() methods control blinking start/stop
Blinking Configuration Properties - blinkOnChange: Enables or disables blinking functionality - toggleMode: Selects blinking pattern:
Normal mode: Starts blinking when value changes from 1→0, stops when 0→1
Toggle mode: Starts blinking when value changes from 0→1, stops when 1→0
blinkColor1 and blinkColor2: Two alternating blink colors
blinkInterval: Blinking interval time in milliseconds
Value Change Handling - In value_changed() method, monitors transitions between 0 and 1 values - Automatically starts/stops blinking based on selected mode and value transitions - Maintains previous value state for comparison
Indicator Color Update - In update_indicators() method, determines which bits should blink - Toggle mode: Only bits with value 1 blink - Normal mode: Only bits with value 0 blink - Non-blinking bits display normal on/off colors
Backward Compatibility - Default blinkOnChange = False ensures existing code remains unaffected - All original functionality (layout, orientation, endianness, labels) preserved - Blinking only activates when explicitly setting blinkOnChange = True - Single unified class instead of separate classes for cleaner maintenance