Skip to content

Note

Click here to download the full example code

Layer manipulator (library)

An example controlling the layer manipulator, using napari-threedee as a library.

layer manipulator library

Out:

/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_migration.py:283: UserWarning: `pydantic.generics:GenericModel` has been moved to `pydantic.BaseModel`.
  warnings.warn(f'`{import_path}` has been moved to `{new_location}`.')
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_mutation' has been removed
  warnings.warn(message, UserWarning)
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_mutation' has been removed
  warnings.warn(message, UserWarning)
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_mutation' has been removed
  warnings.warn(message, UserWarning)
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_mutation' has been removed
  warnings.warn(message, UserWarning)
/opt/hostedtoolcache/Python/3.9.20/x64/lib/python3.9/site-packages/pydantic/_internal/_config.py:341: UserWarning: Valid config keys have changed in V2:
* 'allow_mutation' has been removed
  warnings.warn(message, UserWarning)
/home/runner/work/napari-threedee/napari-threedee/src/napari_threedee/utils/napari_utils.py:65: FutureWarning: Access to QtViewer.view is deprecated since 0.5.0 and will be removed in the napari 0.6.0. Change to QtViewer.canvas.view instead.
  return qt_viewer.view.scene


import napari
import numpy as np

from napari_threedee.manipulators._qt import QtLayerManipulatorWidget

data = np.random.random((100, 100, 100))

viewer = napari.view_image(data)
image_layer = viewer.layers[0]

viewer.dims.ndisplay = 3

widget = QtLayerManipulatorWidget(viewer)
viewer.window.add_dock_widget(widget)

napari.run()

Total running time of the script: ( 0 minutes 4.370 seconds)

Download Python source code: layer_manipulator_library.py

Download Jupyter notebook: layer_manipulator_library.ipynb

Gallery generated by mkdocs-gallery