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
ParameterTreeis contained in aQPopBarwhich 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
 
- 
add_subdisplay(name, display, category)[source]¶ Add an arbitrary widget to the tree of available widgets and tools.
- 
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
- 
classmethod 
from_device(device, parent=None, tools=<object object>, pin=False, **kwargs)[source]¶ Create a new
TyphosSuitefrom 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.
dictshould be name, class pairs. By default these will be.default_tools, butNonecan 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.
dictshould be name, class pairs. By default these will be.default_tools, butNonecan 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.
- 
save()[source]¶ Save suite settings to a file using
typhos.utils.save_suite().A
QFileDialogwill 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:])
- 
show_subdisplay(widget)[source]¶ Open a display in the dock system.
- Parameters
 widget (QWidget, SidebarParameter or str) – If given a
SidebarParameterfrom the tree, the widget will be shown and the sidebar item update. Otherwise, the information is passed toget_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 aQScrollArea. 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.
- 
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
 - Returns
 - 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.
- 
scrollable¶ 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.
- 
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.
- 
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
- 
 
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.
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 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.
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 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 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 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 the custom context menu.
Embedded Detailed Engineering ------------- Refresh templates ------------- Kind filter > Show hinted ... Show only hinted Filter by name Hide Empty Panels
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
TyphosSignalPanelin 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.