Note
Go to the end to download the full example as a Python script or as a Jupyter notebook.
Drag and Drop Python Code Example#
This example demonstrates how to execute a python script by drag’n’drop
To use this example, open napari and drag this file into the viewer.

<napari._qt.widgets.qt_viewer_dock_widget.QtViewerDockWidget object at 0x7f92559f5a20>
from napari import Viewer
from napari.types import ImageData
def add_layers(img1: ImageData, img2: ImageData) -> ImageData:
return img1 + img2
viewer = Viewer()
viewer.open_sample('napari', 'cells3d')
viewer.window.add_function_widget(add_layers)