hyperspy.ui_registry module

Registry of user interface widgets.

Format {“tool_key” : {“toolkit” : <function(obj, display, **kwargs)>}}

The tool_key` is defined by the "model function" to which the widget provides and user interface. That function gets the widget function from this registry and executes it passing the ``obj, display and any extra keyword arguments. When display is true, function displays the widget. If False it returns a dictionary with whatever is needed to display the widgets externally (usually for testing or customisation purposes).

hyperspy.ui_registry.add_gui_method(toolkey)
hyperspy.ui_registry.get_gui(self, toolkey, display=True, toolkit=None, **kwargs)
hyperspy.ui_registry.get_partial_gui(toolkey)
hyperspy.ui_registry.register_toolkey(toolkey)

Register a toolkey.

Parameters:toolkey (string) –
hyperspy.ui_registry.register_widget(toolkit, toolkey)

Decorator to register a UI widget.

Parameters:
  • f (function) – Function that returns or display the UI widget. The signature must include obj, display and **kwargs.
  • toolkit (string) – The name of the widget toolkit e.g. ipywidgets
  • toolkey (string) – The “key” of the tool for which the widget provides an interface. If the toolkey is not in the UI_REGISTRY dictionary a NameError is raised.
Returns:

widgets – Dictionary containing the widget objects if display is False, else None.

Return type:

dictionary or None