mdadash.backend.widgets.base

Base Class for Widgets and Widget Manager

Classes

WidgetBase()

This is the base class for all widgets.

WidgetManager()

This is the manager that manager all widgets.

class mdadash.backend.widgets.base.WidgetBase[source]

Bases: ABC

This is the base class for all widgets.

on_input_change(attribute: str, old_value: Any, new_value: Any)[source]

on_input_change handler

This handler is called after a widget input has changed. Validations can be performed in this handler and any exceptions raised with messages will show up as errors in the UI

Parameters:
  • attribute (str) – The input attribute that changed

  • old_value (Any) – The previous value held by this attribute

  • new_value (Any) – The current value of this attribute

post_connect()[source]

post_connect handler

This handler is called after connecting to the simulation

post_disconnect()[source]

post_disconnect handler

This handler is called after disconnection from simulation

post_pause()[source]

post_pause handler

This handler is called after user pauses trajectory iteration

pre_resume()[source]

pre_resume handler

This handler is called after user resumes trajectory iteration

abstractmethod run()[source]

Run method that derived classes implement

class mdadash.backend.widgets.base.WidgetManager[source]

Bases: object

This is the manager that manager all widgets.

add_widget_instance(uid: int, widget_name: str) str | None[source]

Add widget instance

Add a widget instance based on the widget name already registered with the manager.

Parameters:
  • uid (int) – Universe ID (index into universes array)

  • widget_name (str) – Name of the widget class registered

Return type:

uuid of instance added or None

property classes

Dictionary of registered widget classes keyed by widget name

delete_widget_instance(uuid: str) str | None[source]

Remove widget instance

Remove widget instance based on uuid returned during the instance creation using add_widget_instance()

Parameters:

uuid (str) – The uuid of the instance to be removed

Return type:

uuid of instance deleted or None

duplicate_widget_instance(uid: int, uuid: str) str | None[source]

Duplicate widget instance

Duplicate widget instance based on existing instance uuid

Parameters:
  • uid (int) – Universe ID (index into universes array)

  • uuid (str) – The uuid of the instance to be duplicated

Return type:

uuid of new instance created

get_inputs(uuid: str) list[source]

Get inputs for widget instance

Parameters:

uuid (str) – The uuid of the widget instance

Returns:

response – List of input dicts

Return type:

list

property instances

Dictionary of widget instances keyed by widget uuid

classmethod register_class(widget_class: WidgetBase) None[source]

Register widget class

Parameters:

widget_class – A widget class that is derived from WidgetBase

run_widgets(uid: int) None[source]

Run widget instances

Parameters:

uid (int) – Universe ID (index into universes array)

set_input(uuid: str, attribute: str, value: Any) bool[source]

Set input for a widget instance attribute

Parameters:
  • uuid (str) – The uuid of the widget instance

  • attribute (str) – The input attribute to set

  • value (Any) – The value to set for the attribute

Returns:

response – True or False to indicate if input validation succeeded

Return type:

bool