napari.utils.notifications.Notification#

class napari.utils.notifications.Notification(message: str, severity: str | NotificationSeverity = NotificationSeverity.WARNING, actions: Sequence[Tuple[str, Callable[[], None]]] = (), **kwargs)[source]#

Bases: Event

A Notifcation event. Usually created by NotificationManager.

Parameters:
  • message (str) – The main message/payload of the notification.

  • severity (str or NotificationSeverity, optional) – The severity of the notification, by default NotificationSeverity.WARNING.

  • actions (sequence of tuple, optional) – Where each tuple is a (str, callable) 2-tuple where the first item is a name for the action (which may, for example, be put on a button), and the callable is a callback to perform when the action is triggered. (for example, one might show a traceback dialog). by default ()

Methods

from_exception(exc, **kwargs)

from_warning(warning, **kwargs)

Attributes

blocked

This boolean property indicates whether the event will be delivered to event callbacks.

handled

This boolean property indicates whether the event has already been acted on by an event handler.

message

native

source

The object that the event applies to (i.e. the source of the event).

sources

List of objects that the event applies to (i.e. are or have been a source of the event).

type

Details

property blocked: bool#

This boolean property indicates whether the event will be delivered to event callbacks. If it is set to True, then no further callbacks will receive the event. When possible, it is recommended to use Event.handled rather than Event.blocked.

property handled: bool#

This boolean property indicates whether the event has already been acted on by an event handler. Since many handlers may have access to the same events, it is recommended that each check whether the event has already been handled as well as set handled=True if it decides to act on the event.

property source: Any#

The object that the event applies to (i.e. the source of the event).

property sources: List[Any]#

List of objects that the event applies to (i.e. are or have been a source of the event). Can contain multiple objects in case the event traverses a hierarchy of objects.