Widgets¶
Typhos uses a few custom widgets to create a clean and concise user interface. While most users should not be interacting with these directly, there may be a need if a user opts to create their display by hand instead of automatically generating one.
Determining widget types¶
If you would just like a widget for an ophyd.Signal
, there
is a function available:
-
typhos.widgets.
create_signal_widget
(signal, read_only=False, tooltip=None)[source]¶ Factory for creating a PyDMWidget from a signal
- Parameters
- Returns
widget – PyDMLabel, PyDMLineEdit, or PyDMEnumComboBox based on whether we should be able to write back to the widget and if the signal has
enum_strs
- Return type
PyDMWidget
-
class
typhos.widgets.
SignalWidgetInfo
(read_cls, read_kwargs, write_cls, write_kwargs)[source]¶ Provides information on how to create signal widgets: class and kwargs.
- Parameters
-
typhos.widgets.
widget_type_from_description
(signal, desc, read_only=False)[source]¶ Determine which widget class should be used for the given signal
- Parameters
- Returns
widget_class (class) – The class to use for the widget
kwargs (dict) – Keyword arguments for the class
-
typhos.widgets.
determine_widget_type
(signal, read_only=False)[source]¶ Determine which widget class should be used for the given signal.
- Parameters
signal (ophyd.Signal) – Signal object to determine widget class
read_only (bool, optional) – Should the chosen widget class be read-only?
- Returns
widget_class (class) – The class to use for the widget
kwargs (dict) – Keyword arguments for the class
Panels¶
One of the major design principles of Typhos is that users should be able to see what they need and hide one they don’t. Thefore, many of the widget implementations are placed in “Panels” these consist of QPushButton header that hides and shows the contents. Each variation in Typhos is documented below.
Basic Signal Panels¶
-
class
typhos.panel.
SignalPanel
(signals=None)[source]¶ Basic panel layout for
ophyd.Signal
and other ophyd objects.This panel does not support hierarchical display of signals; rather, it flattens a device hierarchy showing all signals in the same area.
- Parameters
signals (OrderedDict, optional) – Signals to include in the panel. Parent of panel.
-
loading_complete
¶ A signal indicating that loading of the panel has completed.
- Type
QtCore.Signal
See also
-
add_row
(*widgets, **kwargs)[source]¶ Add
widgets
to the next row.If fewer than
NUM_COLS
widgets are given, the last widget will be adjusted automatically to span the remaining columns.- Parameters
*widgets – List of
QtWidgets.QWidget
.- Returns
row – The row number.
- Return type
-
add_signal
(signal, name=None, *, tooltip=None)[source]¶ Add a signal to the panel.
The type of widget control that is drawn is dependent on
_read_pv
, and_write_pv
. attributes.If widget information for the given signal is available in the global cache, the widgets will be created immediately. Otherwise, a row will be reserved and widgets created upon signal connection and background description callback.
-
filter_signals
(kinds, name_filter=None)[source]¶ Filter signals based on the given kinds.
- Parameters
kinds (list of
ophyd.Kind
) – List of kinds to show.name_filter (str, optional) – Additionally filter signals by name.
-
label_text_from_attribute
(attr, dotted_name)[source]¶ Get label text for a given attribute.
For a basic signal panel, use the full dotted name. This is because this panel flattens the device hierarchy, and using only the last attribute name may lead to ambiguity or name clashes.
-
property
row_count
¶ Get the number of filled-in rows.
-
property
signals
¶ Get all instantiated signals, omitting components.
- Returns
signals – With the form:
{signal_name: signal}
.- Return type
-
property
visible_elements
¶ Get all signals visible according to filters, omitting components.
- Returns
signals – With the form:
{signal_name: signal}
.- Return type
-
class
typhos.
TyphosSignalPanel
(parent=None, init_channel=None)[source]¶ Panel of Signals for a given device, using
SignalPanel
.- Parameters
parent (QtWidgets.QWidget, optional) – The parent widget.
init_channel (str, optional) – The PyDM channel with which to initialize the widget.
-
class
SignalOrder
¶ Options for sorting signals.
This can be used as a base class for subclasses of
QtWidgets.QWidget
, allowing this to be used inQtCore.Property
and therefore in the Qt designer.
-
property
filter_settings
¶ Get the filter settings dictionary.
Generate a context menu for this TyphosSignalPanel.
-
nameFilter
¶ Get or set the current name filter.
Open a context menu when the Default Context Menu is requested.
- Parameters
ev (QEvent) –
-
showConfig
¶ Show ophyd.Kind.config signals
-
showHints
¶ Show ophyd.Kind.hinted signals
-
showNormal
¶ Show ophyd.Kind.normal signals
-
showOmitted
¶ Show ophyd.Kind.omitted signals
-
property
show_kinds
¶ Get a list of the
ophyd.Kind
that should be shown.
-
sortBy
¶ Get or set the order that the signals will be placed in layout.
Composite Signal Panels¶
-
class
typhos.panel.
CompositeSignalPanel
[source]¶ Composite panel layout for
ophyd.Signal
and other ophyd objects.Contrasted to
SignalPanel
, this class retains the hierarchy built into anophyd.Device
hierarchy. Individual signals mix in with sub-device displays, which may or may not have custom screens.-
loading_complete
¶ A signal indicating that loading of the panel has completed.
- Type
QtCore.Signal
-
add_sub_device
(device, name)[source]¶ Add a sub-device to the next row.
- Parameters
device (ophyd.Device) – The device to add.
name (str) – The name/label to go with the device.
-
property
visible_elements
¶ Return all visible signals and components.
-
TyphosPositionerWidget¶
-
class
typhos.
TyphosPositionerWidget
(parent=None)[source]¶ Widget to interact with a
ophyd.Positioner
.Standard positioner motion requires a large amount of context for operators. For most motors, it may not be enough to simply have a text field where setpoints can be punched in. Instead, information like soft limits and hardware limit switches are crucial for a full understanding of the position and behavior of a motor. The widget will work with any object that implements the method
set
, however to get other relevant information, we see if we can find other useful signals. Below is a table of attributes that the widget looks for to inform screen design.Widget
Attribute Selection
User Readback
The
readback_attribute
property is used, which defaults touser_readback
. Linked to UI elementuser_readback
.User Setpoint
The
setpoint_attribute
property is used, which defaults touser_setpoint
. Linked to UI elementuser_setpoint
.Limit Switches
The
low_limit_switch_attribute
andhigh_limit_switch_attribute
properties are used, which default tolow_limit_switch
andhigh_limit_switch
, respectively.Soft Limits
The
low_limit_travel_attribute
andhigh_limit_travel_attribute
properties are used, which default tolow_limit_travel
andhigh_limit_travel
, respectively. As a fallback, thelimit
property on the device may be queried directly.Set and Tweak
Both of these methods simply use
Device.set
which is expected to take afloat
and return astatus
object that indicates the motion completeness. Must be implemented.Stop
Device.stop()
-
acceleration_attribute
¶ The attribute name for the acceleration time signal.
-
property
device
¶ The associated device.
-
failed_move
¶ The last requested move failed
-
high_limit_switch_attribute
¶ The attribute name for the high limit switch signal.
-
high_limit_travel_attribute
¶ The attribute name for the high (soft) limit travel signal.
-
low_limit_switch_attribute
¶ The attribute name for the low limit switch signal.
-
low_limit_travel_attribute
¶ The attribute name for the low limit signal.
-
moving
¶ Current state of widget
This will lag behind the actual state of the positioner in order to prevent unnecessary rapid movements
-
readback_attribute
¶ The attribute name for the readback signal.
-
setpoint_attribute
¶ The attribute name for the setpoint signal.
-
successful_move
¶ The last requested move was successful
-
velocity_attribute
¶ The attribute name for the velocity signal.
-
Functions and Methods¶
-
class
typhos.func.
FunctionPanel
(methods=None, parent=None)[source]¶ Function Panel.
Similar to
SignalPanel
but instead displays a set of function widgets arranged in a row. Each provided method has aFunctionDisplay
generated for it an added to the layout.- Parameters
methods (list of callables, optional) – List of callables to add to the FunctionPanel.
parent (QWidget) –
-
add_method
(func, *args, **kwargs)[source]¶ Add a
FunctionDisplay
.- Parameters
func (callable) – Annotated callable function.
args – All additional parameters are passed directly to the
FunctionDisplay
constructor.kwargs – All additional parameters are passed directly to the
FunctionDisplay
constructor.
-
class
typhos.
TyphosMethodButton
(parent=None)[source]¶ QPushButton to access a method of a Device.
The function provided by the loaded device and the
method_name
will be run when the button is clicked. Ifuse_status
is set to True, the button will be disabled while theStatus
object is active.-
method_name
¶ Name of method on provided Device to execute.
-
use_status
¶ Use the status to enable and disable the button.
-
Miscellaneous¶
-
class
typhos.widgets.
ClickableBitIndicator
(parent=None, circle=False)[source]¶ A bit indicator that emits clicked when clicked.
-
class
typhos.widgets.
ImageDialogButton
(init_channel, text=None, icon=None, parent=None)[source]¶ QPushButton to show a 2-d array.
Notes
Used for variety array-image (readback)
-
parent_widget_class
¶ alias of
PyQt5.QtWidgets.QMainWindow
-
class
typhos.widgets.
SignalDialogButton
(init_channel, text=None, icon=None, parent=None)[source]¶ QPushButton to launch a QDialog with a PyDMWidget
-
parent_widget_class
¶ alias of
PyQt5.QtWidgets.QWidget
-
-
class
typhos.widgets.
TyphosArrayTable
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ A table widget which reshapes and displays a given waveform value.
Notes
Used for variety array-tabular (setpoint)
-
value_changed
(value)[source]¶ Callback invoked when the Channel value is changed.
- Parameters
new_waveform (np.ndarray) – The new waveform value from the channel.
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.widgets.
TyphosByteIndicator
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ Displays an integer value as individual, read-only bit indicators.
Notes
Used for variety bitmask (readback)
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.widgets.
TyphosByteSetpoint
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ Displays an integer value as individual, toggleable bit indicators.
Notes
Used for variety bitmask (setpoint)
-
numBits
¶ Number of bits to interpret.
Re-implemented from PyDM to support changing of bit indicators.
-
class
typhos.widgets.
TyphosComboBox
(parent=None, init_channel=None)[source]¶ Notes
Used for variety text-enum (setpoint)
Used for variety enum (setpoint)
-
class
typhos.widgets.
TyphosCommandButton
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ A pushbutton widget which executes a command by sending a specific value.
See also
Notes
Used for variety command-setpoint-tracks-readback (setpoint)
Used for variety command-proc (setpoint)
Used for variety command (setpoint)
-
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
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.widgets.
TyphosCommandEnumButton
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ A group of buttons which represent several command options.
These options can come from directly from the control layer or can be overridden with variety metadata.
See also
Notes
Used for variety command-enum (setpoint)
-
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
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.widgets.
TyphosLabel
(*args, display_format=None, **kwargs)[source]¶ Reimplementation of PyDMLabel to set some custom defaults
Notes
Used for variety array-nd (setpoint)
Used for variety text-multiline (readback)
Used for variety text-enum (readback)
Used for variety text (readback)
Used for variety scalar-tweakable (readback)
Used for variety scalar-range (readback)
Used for variety scalar (readback)
Used for variety enum (readback)
Used for variety command-setpoint-tracks-readback (readback)
Used for variety command-enum (readback)
Used for variety array-nd (readback)
-
class
typhos.widgets.
TyphosLineEdit
(*args, display_format=None, **kwargs)[source]¶ Reimplementation of PyDMLineEdit to set some custom defaults
Notes
Used for variety text (setpoint)
Used for variety scalar (setpoint)
-
setpointHistoryCount
¶ Number of items to show in the context menu “setpoint history”
-
property
setpoint_history
¶ timestamp}
- Type
History of setpoints, as a dictionary of {setpoint
-
unit_changed
(new_unit)[source]¶ Callback invoked when the Channel has new unit value. This callback also triggers an update_format_string call so the new unit value is considered if
`showUnits`
is set.- Parameters
new_unit (str) – The new unit
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
-
class
typhos.widgets.
TyphosScalarRange
(*args, variety_metadata=None, ophyd_signal=None, **kwargs)[source]¶ A slider widget which displays a scalar value with an explicit range.
Notes
Used for variety scalar-range (setpoint)
-
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.
-
property
delta_signal
¶ Delta signal, used as the source for “delta_value”.
-
delta_value
¶ Delta value, an alternative to “num_points” provided by PyDMSlider.
num_points is calculated using the current min/max and the delta value, if set.
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.widgets.
TyphosSidebarItem
(param, depth)[source]¶ Class to display a Device or Tool in the sidebar
Notes
-
class
typhos.tweakable.
TyphosTweakable
(parent=None, init_channel=None, variety_metadata=None, ophyd_signal=None)[source]¶ Widget for a tweakable scalar.
- Parameters
parent (QWidget) – The parent widget.
init_channel (str, optional) – The channel to be used by the widget.
Notes
Used for variety scalar-tweakable (setpoint)
-
property
variety_metadata
¶ Additional component variety metadata.
-
class
typhos.textedit.
TyphosTextEdit
(parent=None, init_channel=None, variety_metadata=None, ophyd_signal=None)[source]¶ A writable, multiline text editor with support for PyDM Channels.
- Parameters
parent (QWidget) – The parent widget.
init_channel (str, optional) – The channel to be used by the widget.
Used for variety text-multiline (setpoint) (*) –
-
property
variety_metadata
¶ Additional component variety metadata.