napari.utils.NotebookScreenshot#

class napari.utils.NotebookScreenshot(viewer, *, canvas_only=False, alt_text=None)[source]#

Bases: object

Display napari screenshot in the jupyter notebook.

Functions returning an object with a _repr_png_() method will displayed as a rich image in the jupyter notebook.

https://ipython.readthedocs.io/en/stable/api/generated/IPython.display.html

Parameters:
  • viewer (napari.Viewer) – The napari viewer.

  • canvas_only (bool, optional) – If True includes the napari viewer frame in the screenshot, otherwise just includes the canvas. By default, True.

Examples

>>> import napari
>>> from napari.utils import nbscreenshot
>>> from skimage.data import chelsea
>>> viewer = napari.view_image(chelsea(), name='chelsea-the-cat')
>>> nbscreenshot(viewer)
# screenshot just the canvas with the napari viewer framing it
>>> nbscreenshot(viewer, canvas_only=False)

Methods

Details