Abstract interfaces and type definitions.

class nova.mvvm.interface.BindingInterface

Abstract binding interface.

abstractmethod new_bind(linked_object: Any | None = None, linked_object_arguments: list[str] | None = None, callback_after_update: None | Callable[[dict[str, Any]], None] | Callable[[dict[str, Any]], Coroutine[Any, Any, None]] = None) Communicator

Bind a ViewModel or Model variable to a GUI framework element, allowing for synchronized updates.

This method creates a binding between a variable in a ViewModel/Model and a corresponding element in the GUI.

Parameters:
  • linked_object (object, dictionary or function, optional) – Instance to link with the ViewModel/Model variable. When specified, changes in View trigger update for this instance. We recommend to use a Pydantic model as an object since it provides the means to validate data and use model metadate in GUI (like title, tips, …)

  • linked_object_arguments (list of str, optional, ignored with Pydantic model) – If the linked_object is a class instance(object) one can provide a list of argument names associated with linked_object that define specific attributes to bind. If not provided, the default behavior is to bind all attributes.

  • callback_after_update (Callable, optional) – A function to be called after each update to linked_object. Useful for additional actions or processing post-update.

Returns:

An object that manages the binding, allowing updates to propagate between the ViewModel/Model variable and the GUI framework element.

Return type:

Communicator

abstractmethod new_worker(task: Callable[[...], Any], *args: Any, **kwargs: Any) Worker

Creates an instance of a Worker class to be used to run tasks in background.

class nova.mvvm.interface.Communicator

Abstract communicator class.

Provides methods required for binding to communicate between ViewModel and View.

abstractmethod connect(*args: Any) None | Callable[[Any, str | None], None]

Connect a GUI element to a linked object.

This method should be called from the View side to establish a connection between a GUI element and a linked object, which is passed during the bind creation from the ViewModel side.

Parameters:

connector (Any, optional) – The GUI element or object to connect. None can be used in some implementations to indicate that GUI element(s) should be automatically identified using the linked object.

Returns:

  • Union[None, Callable]

  • Depending on the specific implementation, returns None or a callback function

  • that can be used to update the linked object.

abstractmethod update_in_view(value: Any) None

Update UI component(s) with the provided value.

Parameters:

value (Any) – The new value to be reflected in the view.

Returns:

This method does not return a value.

Return type:

None

class nova.mvvm.interface.Worker

Abstract worker class.

Provides methods required to run tasks in backend.

abstractmethod connect_error(callback: Callable[[Exception], None]) None

Register a callback to be called if the task raises an exception.

Parameters:

callback (Callable[[Exception], None]) – Function called with the exception.

abstractmethod connect_finished(callback: Callable[[], None]) None

Register a callback to be called when the task has finished (success or failure).

Parameters:

callback (Callable[[], None]) – Function called with no arguments.

abstractmethod connect_progress(callback: Any) None

Register a callback to be called with progress updates (0 to 100).

Parameters:

callback (Callable[[float], None]) – Function called with a float progress value.

abstractmethod connect_result(callback: Callable[[Any], None]) None

Register a callback to be called with the result when the task finishes.

Parameters:

callback (Callable[[Any], None]) – Function called with the result.

abstractmethod start() None

Start running the task in a background thread.