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=None, *, pin=False)[source]

This suite combines tools and devices into a single widget.

A ParameterTree is contained in a QPopBar 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.

default_tools

The default tools to use in the suite. In the form of {'tool_name': ToolClass}.

Type

dict

add_device(device, children=True, category='Devices')[source]

Add a device to the suite.

Parameters
  • device (ophyd.Device) – The device to add.

  • children (bool, optional) – Also add any subdevices of this device to the suite as well.

  • category (str, optional) – Category of device. By default, all devices will just be added to the “Devices” group

add_subdisplay(name, display, category)[source]

Add an arbitrary widget to the tree of available widgets and tools.

Parameters
  • name (str) – Name to be displayed in the tree

  • display (QWidget) – QWidget to show in the dock when expanded.

  • category (str) – The top level group to place the controls under in the tree. If the category does not exist, a new one will be made

add_tool(name, tool)[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

embed_subdisplay(widget)[source]

Embed a display in the dock system.

classmethod from_device(device, parent=None, tools=<object object>, pin=False, **kwargs)[source]

Create a new TyphosSuite from an ophyd.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, but None can be passed to avoid tool loading completely.

  • **kwargs – Passed to TyphosSuite.add_device()

classmethod from_devices(devices, parent=None, tools=<object object>, pin=False, **kwargs)[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, but None can be passed to avoid tool loading completely.

  • **kwargs – Passed to TyphosSuite.add_device()

get_subdisplay(display)[source]

Get a subdisplay by name or contained device.

Parameters

display (str or Device) – Name of screen or device

Returns

widget – Widget that is a member of the ui.subdisplay

Return type

QWidget

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.

hide_subdisplays()[source]

Hide all open displays.

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 file

The 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:])
show_subdisplay(widget)[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 to get_subdisplay()

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=None, *, scrollable=True, composite_heuristics=True, embedded_templates=None, detailed_templates=None, engineering_templates=None, display_type='detailed_screen', nested=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) – If True, put the loaded template into a QScrollArea. Otherwise, the display widget will go directly in this widget’s layout.

  • composite_heuristics (bool, optional) – Enable composite heuristics, which may change the suggested detailed screen based on the contents of the added device. See also suggest_composite_screen().

  • 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, optional) – The default display type.

  • 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.
Parameters
  • device (ophyd.Device) – The device to add.

  • macros (dict, optional) – Additional macros to use/replace the defaults.

composite_heuristics

Allow composite screen to be suggested first by heuristics.

copy_to_clipboard()[source]

Copy the display image to the clipboard.

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.

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
  • klass (str or class) –

  • template (str, optional) – Set the display_template.

  • macros (dict, optional) – Macro substitutions to be placed in template.

  • **kwargs – Extra arguments are used at device instantiation.

Returns

Return type

TyphosDeviceDisplay

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

Parameters
  • device (ophyd.Device) –

  • template (str, optional) – Set the display_template.

  • macros (dict, optional) – Macro substitutions to be placed in template.

  • **kwargs – Passed to the class init.

get_best_template(display_type, macros)[source]

Get the best template for the given display type.

Parameters
  • display_type (DisplayTypes, str, or int) – The display type.

  • macros (dict) – Macros to use when loading the template.

hideEmpty

Toggle hiding or showing empty panels.

load_best_template()[source]

Load the best available template for the current display type.

property macros

Get or set the macros for the display.

scrollable

Place the display in a scrollable area.

search_for_templates()[source]

Search the filesystem for device-specific templates.

classmethod suggest_composite_screen(device_cls)[source]

Suggest to use the composite screen for the given class.

Returns

composite – If True, favor the composite screen.

Return type

bool

to_image()[source]

Return the entire display as a QtGui.QImage.

Returns

The display, as an image.

Return type

QtGui.QImage

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.

add_device(device)[source]

Typhos hook for setting the associated device.

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.

add_device(device)[source]

Typhos hook for setting the associated device.

set_device_display(display)[source]

Typhos hook for setting the associated device display.

class typhos.display.TyphosTitleLabel[source]

A label class intended for use as a standardized title.

toggle_requested

A Qt signal indicating that the user clicked on the title. By default, this hides any nested panels underneath the title.

Type

QtCore.Signal

mousePressEvent(event)[source]

Overridden qt hook for a mouse press.

Tool buttons

class typhos.display.TyphosToolButton(icon=None, *, parent=None)[source]

Base class for tool buttons used in the TyphosDisplaySwitcher.

Parameters
  • icon (QIcon or str, optional) – See get_icon() for options.

  • parent (QtWidgets.QWidget, optional) – The parent widget.

DEFAULT_ICON

The default icon from fontawesome to use.

Type

str

generate_context_menu()[source]

Context menu request: override in subclasses.

classmethod get_icon(icon=None)[source]

Get a QIcon, if specified, or fall back to the default.

Parameters

icon (str or QtGui.QIcon) – If a string, assume it is from fontawesome. Otherwise, use the icon instance as-is.

open_context_menu(ev)[source]

Open the instance-specific context menu.

Parameters

ev (QEvent) –

class typhos.display.TyphosDisplaySwitcherButton(display_type, *, parent=None)[source]

A button which switches the TyphosDeviceDisplay template on click.

generate_context_menu()[source]

Context menu request.

class typhos.display.TyphosDisplayConfigButton(icon=None, *, parent=None)[source]

The configuration button used in the TyphosDisplaySwitcher.

This uses the common “vertical ellipse” icon by default.

create_hide_empty_menu(panels, base_menu)[source]

Create the hide empty filtering menu.

Parameters
  • panels (list of TyphosSignalPanel) – The panels to filter upon triggering of menu actions.

  • base_menu (QMenu) – The menu to add actions to.

create_kind_filter_menu(panels, base_menu, *, only)[source]

Create the “Kind” filter menu.

Parameters
  • panels (list of TyphosSignalPanel) – The panels to filter upon triggering of menu actions.

  • base_menu (QMenu) – The menu to add actions to.

  • only (bool) – False - create “Show Kind” actions. True - create “Show only Kind” actions.

create_name_filter_menu(panels, base_menu)[source]

Create the name-based filtering menu.

Parameters
  • panels (list of TyphosSignalPanel) – The panels to filter upon triggering of menu actions.

  • base_menu (QMenu) – The menu to add actions to.

generate_context_menu()[source]

Generate the custom context menu.

Embedded
Detailed
Engineering
-------------
Refresh templates
-------------
Kind filter > Show hinted
              ...
              Show only hinted
Filter by name
Hide Empty Panels
hide_empty(search=True)[source]

Wrap hide_empty calls for use with search functions and action clicks.

Parameters

search (bool) – Whether or not this method is being called from a search/filter method.

set_device_display(device_display)[source]

Typhos callback: set the TyphosDeviceDisplay.

Utilities

typhos.display.normalize_display_type(display_type)[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.