Widget communication#
Sometimes complex workflows require access to other docked widgets, information from other plugins, which may be created by other developers.
Access another plugin widget with viewer.window.add_plugin_dock_widget
#
If a desired plugin widget is already docked in the viewer,
calling the add_plugin_dock_widget
method will return the existing widget instance.
If the desired widget is absent, it will be created and added to the viewer.
add_plugin_dock_widget
is the most convenient way to access a plugin widget that is required by your plugin.
Access a widget by name with viewer.window.dock_widgets
#
If the goal is to access a target widget, without creating a widget, use the dock_widgets
property.
The dock_widgets
property provides access to a read-only mapping of all docked widgets in the viewer.
This method returns the widget itself, not the QtViewerDockWidget
wrapper.
The dock_widgets
property was added in napari 0.6.2.
Widget name#
When a widget is added to the viewer via a plugin contribution (by using a menu or add_plugin_dock_widget
), it is assigned a name.
The name is created by concatenating the widget display_name
from the plugin manifest and the plugin name in parentheses, like this: "Widget name (plugin_name)"
. Note: this is the same name that is shown in the napari menus and the title bar of the widget.
Important
We don’t recommend using the viewer.window._dock_widgets
attribute to access QtViewerDockWidget
widgets. This is a private, internal API and may stop working on any release. Please use the above described public API instead.