Suite and Displays
Typhos has two major widgets that users are expected to interface with. The
first is the TyphosDeviceDisplay
, which shows device information, and
TyphosSuite
which contains multiple devices and tools. This is the
barebones implementation. No signals, or widgets are automatically populated in
the screen. In fact, by default most of the widgets will be hidden. You can
then manually add signals to the panels and plots, the panels will only show
themselves when you add PVs.
TyphosSuite
- class typhos.TyphosSuite(parent: QtWidgets.QWidget | None = None, *, pin: bool = False, content_layout: QtWidgets.QLayout | None = None, default_display_type: DisplayTypes = DisplayTypes.embedded_screen, scroll_option: ScrollOptions = ScrollOptions.auto)[source]
This suite combines tools and devices into a single widget.
A
ParameterTree
is contained in aQPopBar
which shows tools and the hierarchy of a device along with options to show or hide them.- Parameters:
parent (QWidget, optional)
pin (bool, optional) – Pin the parameter tree on startup.
content_layout (QLayout, optional) – Sets the layout for when we have multiple subdisplays open in the suite. This will have a horizontal layout by default but can be changed as needed for the use case.
default_display_type (DisplayType, optional) – DisplayType enum that determines the type of display to open when we add a device to the suite. Defaults to DisplayType.detailed_screen.
scroll_option (ScrollOptions, optional) – ScrollOptions enum that determines the behavior of scrollbars in the suite. Default is ScrollOptions.auto, which enables scrollbars for detailed and engineering screens but not for embedded displays.
- default_tools
The default tools to use in the suite. In the form of
{'tool_name': ToolClass}
.- Type:
- add_lazy_subdisplay(name: str, display_class: type[QWidget], category: str)[source]
Add an arbitrary widget to the tree of available widgets and tools.
- add_subdisplay(name, display, category)[source]
Add an arbitrary widget to the tree of available widgets and tools.
- add_tool(name: str, tool: type[QWidget])[source]
Add a widget to the toolbar.
Shortcut for:
suite.add_subdisplay(name, tool, category='Tools')
- Parameters:
name (str) – Name of tool to be displayed in sidebar
tool (QWidget) – Widget to be added to
.ui.subdisplay
- classmethod from_device(device: Device, parent: QtWidgets.QWidget | None = None, tools: dict[str, type] | None | DEFAULT_TOOLS = <object object>, pin: bool = False, content_layout: QtWidgets.QLayout | None = None, default_display_type: DisplayTypes = DisplayTypes.detailed_screen, scroll_option: ScrollOptions = ScrollOptions.auto, show_displays: bool = True, **kwargs) TyphosSuite [source]
Create a new
TyphosSuite
from anophyd.Device
.- Parameters:
device (ophyd.Device) – The device to use.
children (bool, optional) – Choice to include child Device components
parent (QWidget)
tools (dict, optional) – Tools to load for the object.
dict
should be name, class pairs. By default these will be.default_tools
, butNone
can be passed to avoid tool loading completely.pin (bool, optional) – Pin the parameter tree on startup.
content_layout (QLayout, optional) – Sets the layout for when we have multiple subdisplays open in the suite. This will have a horizontal layout by default but can be changed as needed for the use case.
default_display_type (DisplayTypes, optional) – DisplayTypes enum that determines the type of display to open when we add a device to the suite. Defaults to DisplayTypes.detailed_screen.
scroll_option (ScrollOptions, optional) – ScrollOptions enum that determines the behavior of scrollbars in the suite. Default is ScrollOptions.auto, which enables scrollbars for detailed and engineering screens but not for embedded displays.
show_displays (bool, optional) – If True (default), open all the included device displays. If False, do not open any of the displays.
**kwargs – Passed to
TyphosSuite.add_device()
- classmethod from_devices(devices: list[Device], parent: QtWidgets.QWidget | None = None, tools: dict[str, type] | None | DEFAULT_TOOLS = <object object>, pin: bool = False, content_layout: QtWidgets.QLayout | None = None, default_display_type: DisplayTypes = DisplayTypes.detailed_screen, scroll_option: ScrollOptions = ScrollOptions.auto, show_displays: bool = True, **kwargs) TyphosSuite [source]
Create a new TyphosSuite from an iterator of
ophyd.Device
- Parameters:
device (ophyd.Device)
children (bool, optional) – Choice to include child Device components
parent (QWidget)
tools (dict, optional) – Tools to load for the object.
dict
should be name, class pairs. By default these will be.default_tools
, butNone
can be passed to avoid tool loading completely.pin (bool, optional) – Pin the parameter tree on startup.
content_layout (QLayout, optional) – Sets the layout for when we have multiple subdisplays open in the suite. This will have a horizontal layout by default but can be changed as needed for the use case.
default_display_type (DisplayTypes, optional) – DisplayTypes enum that determines the type of display to open when we add a device to the suite. Defaults to DisplayTypes.detailed_screen.
scroll_option (ScrollOptions, optional) – ScrollOptions enum that determines the behavior of scrollbars in the suite. Default is ScrollOptions.auto, which enables scrollbars for detailed and engineering screens but not for embedded displays.
show_displays (bool, optional) – If True (default), open all the included device displays. If False, do not open any of the displays.
**kwargs – Passed to
TyphosSuite.add_device()
- get_subdisplay(display: Device | str, instantiate: bool = True)[source]
Get a subdisplay by name or contained device.
- Parameters:
- Returns:
widget – Widget that is a member of the
ui.subdisplay
- Return type:
QWidget or partial
Example
suite.get_subdisplay(my_device.x) suite.get_subdisplay('My Tool')
- hide_subdisplay(widget)[source]
Hide a visible subdisplay.
- Parameters:
widget (SidebarParameter or Subdisplay) – If you give a SidebarParameter, we will find the corresponding widget and hide it. If the widget provided to us is inside a DockWidget we will close that, otherwise the widget is just hidden.
- save()[source]
Save suite settings to a file using
typhos.utils.save_suite()
.A
QFileDialog
will be used to query the user for the desired location of the created Python fileThe template will be of the form:
import sys import typhos.cli devices = {devices} def create_suite(cfg=None): return typhos.cli.create_suite(devices, cfg=cfg) if __name__ == '__main__': typhos.cli.typhos_cli(devices + sys.argv[1:])
- save_device_screenshots(filename_format: str) dict[str, str] [source]
Save screenshot(s) of devices to
filename_format
.
- show_subdisplay(widget: QWidget | SidebarParameter | str) QWidget [source]
Open a display in the dock system.
- Parameters:
widget (QWidget, SidebarParameter or str) – If given a
SidebarParameter
from the tree, the widget will be shown and the sidebar item update. Otherwise, the information is passed toget_subdisplay()
- Returns:
widget – The subdisplay that was shown.
- Return type:
QWidget
- property tools
Tools loaded into the suite.
- property top_level_groups
Get top-level groups.
This is of the form:
{'name': QGroupParameterItem}
TyphosDeviceDisplay
- class typhos.TyphosDeviceDisplay(parent: QWidget | None = None, *, scrollable: bool | None = None, embedded_templates: list[str] | None = None, detailed_templates: list[str] | None = None, engineering_templates: list[str] | None = None, display_type: DisplayTypes | str | int = 'embedded_screen', scroll_option: ScrollOptions | str | int = ScrollOptions.auto, nested: bool = False)[source]
Main display for a single ophyd Device.
This contains the widgets for all of the root devices signals, and any methods you would like to display. By typhos convention, the base initialization sets up the widgets and the
from_device()
class method will automatically populate the resulting display.- Parameters:
parent (QWidget, optional) – The parent widget.
scrollable (bool, optional) – Semi-deprecated parameter. Use scroll_option instead. If
True
, put the loaded template into aQScrollArea
. IfFalse
, the display widget will go directly in this widget’s layout. If omitted, scroll_option is used instead.embedded_templates (list, optional) – List of embedded templates to use in addition to those found on disk.
detailed_templates (list, optional) – List of detailed templates to use in addition to those found on disk.
engineering_templates (list, optional) – List of engineering templates to use in addition to those found on disk.
display_type (DisplayTypes, str, or int, optional) – The default display type.
scroll_option (ScrollOptions, str, or int, optional) – The scroll behavior.
nested (bool, optional) – An optional annotation for a display that may be nested inside another.
- TemplateEnum
alias of
DisplayTypes
- add_device(device, macros=None)[source]
Add a Device and signals to the TyphosDeviceDisplay.
The full dictionary of macros is built with the following order of precedence:
1. Macros from the device metadata itself. 2. If available, `name`, and `prefix` will be added from the device. 3. The argument ``macros`` is then used to fill/update the final macro dictionary.
This will also register the device’s signals in the sig:// plugin. This means that any templates can refer to their device’s signals by name.
- Parameters:
device (ophyd.Device) – The device to add.
macros (dict, optional) – Additional macros to use/replace the defaults.
- property current_template
Get the current template being displayed.
- property device
Get the device associated with this Device Display.
- device_class
Get the full class with module name of loaded device.
- device_name
Get the name of the loaded device.
- display_type
Get or set the current display type.
- property display_widget
Get the widget generated from the template.
- property effective_display_type: DisplayTypes
Return the native display type of the current selected template.
It’s possible to request e.g. an embedded screen or an engineering screen and get the detailed screen or tree instead.
This returns the actual type of the screen that was chosen for use in code that needs to respond to the actual template in use, rather than the one requested.
If no template has been selected yet, this falls back to the specified display type.
- force_template
Force a specific template.
- classmethod from_class(klass, *, template=None, macros=None, **kwargs)[source]
Create a new TyphosDeviceDisplay from a Device class.
Loads the signals in to the appropriate positions and sets the title to a cleaned version of the device name.
- Parameters:
- Return type:
- classmethod from_device(device, template=None, macros=None, **kwargs)[source]
Create a new TyphosDeviceDisplay from a Device.
Loads the signals in to the appropriate positions and sets the title to a cleaned version of the device name
- hideEmpty
Toggle hiding or showing empty panels.
- property macros
Get or set the macros for the display.
- scroll_option
Place the display in a scrollable area.
Standardized Display Title
- class typhos.display.TyphosDisplayTitle(title='${name}', *, show_switcher=True, show_underline=True, parent=None)[source]
Standardized Typhos Device Display title.
- Parameters:
title (str, optional) – The initial title text, which may contain macros.
show_switcher (bool, optional) – Show the
TyphosDisplaySwitcher
.show_underline (bool, optional) – Show the underline separator.
parent (QtWidgets.QWidget, optional) – The parent widget.
- set_device_display(display)[source]
Typhos callback: set the
TyphosDeviceDisplay
.
- show_switcher
Get or set whether to show the display switcher.
- show_underline
Get or set whether to show the underline.
- class typhos.display.TyphosDisplaySwitcher(parent=None, **kwargs)[source]
Display switcher set of buttons for use with a TyphosDeviceDisplay.
- set_device_display(display: TyphosDeviceDisplay) None [source]
Typhos hook for setting the associated device display.
Utilities
- typhos.display.normalize_display_type(display_type: DisplayTypes | str | int) DisplayTypes [source]
Normalize a given display type.
- Parameters:
display_type (DisplayTypes, str, or int) – The display type.
- Returns:
display_type – The normalized
DisplayTypes
.- Return type:
DisplayTypes
- Raises:
ValueError – If the input cannot be made a
DisplayTypes
.
- typhos.display.hide_empty(widget, process_widget=True)[source]
Recursively hide empty panels and widgets.
- Parameters:
widget (QWidget) – The widget in which to start the recursive search.
process_widget (bool) – Whether or not to process the visibility for the widget. This is useful since we don’t want to hide the top-most widget otherwise users can’t change the visibility back on.
- typhos.display.show_empty(widget)[source]
Recursively shows all panels and widgets, empty or not.
- Parameters:
widget (QWidget)
- typhos.display.toggle_display(widget, force_state=None)[source]
Toggle the visibility of all
TyphosSignalPanel
in a display.- Parameters:
widget (QWidget) – The widget in which to look for Panels.
force_state (bool) – If set to True or False, it will change visibility to the value of force_state. If not set or set to None, it will flip the current panels state.