napari.utils.notifications.NotificationManager#

class napari.utils.notifications.NotificationManager[source]#

Bases: object

A notification manager, to route all notifications through.

Only one instance is in general available through napari; as we need notification to all flow to a single location that is registered with the sys.except_hook and showwarning hook.

This can and should be used a context manager; the context manager will properly re-entered, and install/remove hooks and keep them in a stack to restore them.

While it might seem unnecessary to make it re-entrant; or to make the re-entrancy no-op; one need to consider that this could be used inside another context manager that modify except_hook and showwarning.

Currently the original except and show warnings hooks are not called; but this could be changed in the future; this poses some questions with the re-entrency of the hooks themselves.

Methods

dispatch(notification)

install_hooks()

Install a sys.excepthook, a showwarning hook and a threading.excepthook to display any message in the UI, storing the previous hooks to be restored if necessary.

receive_error([exctype, value, traceback, ...])

receive_info(message)

receive_thread_error(args)

receive_warning(message, category, filename, ...)

restore_hooks()

Remove hooks installed by install_hooks and restore previous hooks.

Attributes

Details

install_hooks()[source]#

Install a sys.excepthook, a showwarning hook and a threading.excepthook to display any message in the UI, storing the previous hooks to be restored if necessary.

restore_hooks()[source]#

Remove hooks installed by install_hooks and restore previous hooks.