PyDMWidget
API Documentation
- class pydm.widgets.base.PyDMWidget(init_channel=None)[source]
Bases:
PyDMPrimitiveWidget
PyDM base class for Read-Only widgets. This class implements all the functions of connection, alarm handling and more.
- Parameters:
init_channel (str, optional) – The channel to be used by the widget.
- PyDMToolTip
The tooltip for this widget.
- Returns:
toolTip – tooltip info
- Return type:
str
- alarmSensitiveBorder
Whether or not the border color changes when alarm severity changes.
- Returns:
True means that the border color will be changed in case of alarm severity changes.
- Return type:
bool
- alarmSensitiveContent
Whether or not the content color changes when alarm severity changes.
- Returns:
True means that the content color will be changed in case of alarm severity changes.
- Return type:
bool
- alarmSeverityChanged(new_alarm_severity)[source]
PyQT Slot for changes on the Alarm Severity of the Channel This slot sends the severity value to the
`alarm_severity_changed`
callback.- Parameters:
new_alarm_severity (int) –
- alarm_limit_changed(which: AlarmLimit, new_limit: float) None [source]
Callback invoked when the channel receives new alarm limit values.
- Parameters:
which (AlarmLimit) – Which alarm limit was changed. “HIHI”, “HIGH”, “LOW”, “LOLO”
new_limit (float) – New value for the alarm limit
- alarm_severity_changed(new_alarm_severity)[source]
Callback invoked when the Channel alarm severity is changed. This callback is not processed if the widget has no channel associated with it. This callback handles the composition of the stylesheet to be applied and the call to update to redraw the widget with the needed changes for the new state.
- Parameters:
new_alarm_severity (int) – The new severity where 0 = NO_ALARM, 1 = MINOR, 2 = MAJOR and 3 = INVALID
- channel
The channel address in use for this widget.
- Returns:
channel – Channel address
- Return type:
str
- channelValueChanged(new_val)[source]
PyQT Slot for changes on the Value of the Channel This slot sends the value to the
`value_changed`
callback.- Parameters:
new_val (int, float, str, bool or np.ndarray) –
- channels()[source]
Returns the channels being used for this Widget.
- Returns:
channels – List of PyDMChannel objects
- Return type:
list
- channels_for_tools()[source]
Returns a list of channels useful for external tools. The default implementation here is just to return self.channels(), but some widgets will want to re-implement this, especially if they have multiple channels, but only one real ‘signal’ channel.
- Return type:
list
- check_enable_state()[source]
Checks whether or not the widget should be disable. This method also disables the widget and add a Tool Tip with the reason why it is disabled.
- connectionStateChanged(connected)[source]
PyQT Slot for changes on the Connection State of the Channel This slot sends the connection state to the
`connection_changed`
callback.- Parameters:
connected (bool) –
- connection_changed(connected)[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 (int) – When this value is 0 the channel is disconnected, 1 otherwise.
- ctrl_limit_changed(which, new_limit)[source]
Callback invoked when the Channel receives new control limit values.
- Parameters:
which (str) – Which control limit was changed. “UPPER” or “LOWER”
new_limit (float) – New value for the control limit
- enumStringsChanged(new_enum_strings)[source]
PyQT Slot for changes on the string values of the Channel This slot sends the new strings to the
`enum_strings_changed`
callback.- Parameters:
new_enum_strings (tuple) –
- enum_strings_changed(new_enum_strings)[source]
Callback invoked when the Channel has new enum values. This callback also triggers a value_changed call so the new enum values to be broadcasted
- Parameters:
new_enum_strings (tuple) – The new list of values
- eventFilter(obj, event)[source]
Filters events on this object.
Params
- objectQObject
The object that is being handled.
- eventQEvent
The event that is happening.
- returns:
True to stop the event from being handled further; otherwise return false.
- rtype:
bool
Generates the custom context menu, and populates it with any external tools that have been loaded. PyDMWidget subclasses should override this method (after calling superclass implementation) to add the menu.
- Return type:
QMenu
- get_ctrl_limits()[source]
Returns a tuple with the control limits for the channel
- Returns:
(lower, upper) – Lower and Upper control limits
- Return type:
tuple
- init_for_designer()[source]
Method called after the constructor to tweak configurations for when using the widget with the Qt Designer
- lowerCtrlLimitChanged(new_limit)[source]
PyQT Slot for changes on the lower control limit value of the Channel This slot sends the new limit value to the
`ctrl_limit_changed`
callback.- Parameters:
new_limit (float) –
- lower_alarm_limit_changed(new_limit: float)[source]
PyQT slot for changes to the LOLO alarm limit of a PV
- Parameters:
new_limit (float) – The new value for the LOLO limit
- lower_warning_limit_changed(new_limit: float)[source]
PyQT slot for changes to the LOW alarm limit of a PV
- Parameters:
new_limit (float) – The new value for the LOW limit
Handler for when the Default Context Menu is requested.
- Parameters:
ev (QEvent) –
- parseTip(new_tip)[source]
Fetch the object attribute data for the tooltip.
- Parameters:
new_tip (str) – given tooltip string
- Returns:
tip_with_attribute_info – ToolTip string which has had the attribute names replaced with the attribute values.
- Return type:
str
- setX(new_x)[source]
Set the X position of the Widget on the screen.
- Parameters:
new_x (int) – The new X position
- Return type:
None
- setY(new_y)[source]
Set the Y position of the Widget on the screen.
- Parameters:
new_y (int) – The new Y position
- Return type:
None
- set_channel(value)[source]
A setter method without a pyqt decorator so subclasses can use this functionality
- timestamp_changed(new_timestamp)[source]
Callback invoked when the Channel has new timestamp values.
- Parameters:
new_timestamp (float) – The new timestamp value
- upperCtrlLimitChanged(new_limit)[source]
PyQT Slot for changes on the upper control limit value of the Channel This slot sends the new limit value to the
`ctrl_limit_changed`
callback.- Parameters:
new_limit (float) –
- upper_alarm_limit_changed(new_limit: float)[source]
PyQT slot for changes to the HIHI alarm limit of a PV
- Parameters:
new_limit (float) – The new value for the HIHI limit
- upper_warning_limit_changed(new_limit: float)[source]
PyQT slot for changes to the HIGH alarm limit of a PV
- Parameters:
new_limit (float) – The new value for the HIGH limit
- value_changed(new_val)[source]
Callback invoked when the Channel value is changed.
- Parameters:
new_val (str, int, float, bool or np.ndarray) – The new value from the channel. The type depends on the channel.
Fetch the Widget specific context menu which will be populated with additional tools by assemble_tools_menu.
- Returns:
If the return of this method is None a new QMenu will be created by assemble_tools_menu.
- Return type:
QMenu or None
PyDMToolTip Instructions
The PyDMToolTip property field takes a string. In the PyDMToolTip property field, the user can include the tag $(pv_value) to get the value of the channel displayed on the tool tip.
Note
If the toolTip property field is:
The value of the channel is $(pv_value)
The toolTip would read (assuming the value is 10 in this example):
The value of the channel is 10
A period followed by a field name can retrieve other properties of the channel (see the table bellow for all channel properties and associated field names.)
Note
If the toolTip property field is:
The timestamp of the channel is $(pv_value.TIME)
The toolTip would read:
The timestamp of the channel is 2022-09-15 09:56:47.099340
channel properties |
pv_value.field |
Description |
---|---|---|
channel value |
$(pv_value) |
Returns the value of the channel |
channel address |
.address |
Returns the address of the channel |
connection |
.connection |
Returns the connection status |
alarm severity |
.SEVR |
Returns the alarm severity |
enum string |
.enum_strings |
|
engineering unit |
.EGU |
Returns the engineering unit |
precision |
.PREC |
Returns the precision of the channel |
upper ctrl limit |
.DRVH |
Returns the upper ctrl limit |
lower ctrl limit |
.DRVL |
Returns the lower ctrl limit |
upper alarm limit |
.HIHI |
Returns the upper alarm limit |
lower alarm limit |
.LOLO |
Returns the lower alarm limit |
upper warning limit |
.HIGH |
Returns the upper warning limit |
lower warning limit |
.LOW |
Returns the lower warning limit |
timestamp |
.TIME |
Returns the timestamp of the channel |