napari.plugins

Module Attributes

Classes

FunctionType

alias of function

HookImplementation

A class to encapsulate hook implementations.

PluginManager

Core class which manages registration of plugin objects and hook calls.

Functions

napari.plugins.camel_to_spaces(val)[source]
napari.plugins.discover_dock_widgets()[source]

Trigger discovery of dock_widgets plugins

napari.plugins.isclass(object)[source]

Return true if the object is a class.

Class objects provide these attributes:

__doc__ documentation string __module__ name of module in which this class was defined

napari.plugins.magicgui(function=None, *, layout='vertical', labels=True, tooltips=True, call_button=False, auto_call=False, result_widget=False, main_window=False, app=None, persist=False, **param_options)[source]

Return a FunctionGui for function.

Parameters
  • function (Callable, optional) – The function to decorate. Optional to allow bare decorator with optional arguments. by default None

  • layout (str, optional) – The type of layout to use. Must be one of {‘horizontal’, ‘vertical’}. by default “vertical”.

  • labels (bool, optional) – Whether labels are shown in the widget. by default True

  • tooltips (bool, optional) – Whether tooltips are shown when hovering over widgets. by default True

  • call_button (bool or str, optional) – If True, create an additional button that calls the original function when clicked. If a str, set the button text. by default False

  • auto_call (bool, optional) – If True, changing any parameter in either the GUI or the widget attributes will call the original function with the current settings. by default False

  • result_widget (bool, optional) – Whether to display a LineEdit widget the output of the function when called, by default False

  • main_window (bool) – Whether this widget should be treated as the main app window, with menu bar, by default True.

  • app (magicgui.Application or str, optional) – A backend to use, by default None (use the default backend.)

  • persist (bool, optional) – If True, when parameter values change in the widget, they will be stored to disk (in ~/.config/magicgui/cache) and restored when the widget is loaded again with persist = True. By default, False.

  • **param_options (dict of dict) – Any additional keyword arguments will be used as parameter-specific options. Keywords MUST match the name of one of the arguments in the function signature, and the value MUST be a dict.

Returns

result – If function is not None (such as when this is used as a bare decorator), returns a FunctionGui instance, which is a list-like container of autogenerated widgets corresponding to each parameter in the function. If function is None such as when arguments are provided like magicgui(auto_call=True), then returns a function that can be used as a decorator.

Return type

FunctionGui or Callable[[F], FunctionGui]

Examples

>>> @magicgui
... def my_function(a: int = 1, b: str = 'hello'):
...     pass
...
>>> my_function.show()
>>> my_function.a.value == 1  # True
>>> my_function.b.value = 'world'
napari.plugins.register_dock_widget(args, hookimpl)[source]
napari.plugins.register_function_widget(args, hookimpl)[source]
napari.plugins.running_as_bundled_app()[source]

Infer whether we are running as a briefcase bundle

Return type

bool

napari.plugins.signature(obj, *, follow_wrapped=True)[source]

Get a signature object for the passed callable.

napari.plugins.user_site_packages()[source]

Platform-specific location of site-packages folder in user library

Return type

str

napari.plugins.warn(message, category=None, stacklevel=1, source=None)

Issue a warning, or maybe ignore it or raise an exception.