Events reference#
The following tables contain events that you may connect to. For example, to have a specific function called whenever the users
changes the number of dimensions displayed in the viewer (e.g.
from 2D to 3D), you can use <event>.connect(your_callback)
:
from napari.utils.events import Event
from napari import Viewer
def my_callback(event: Event):
print("The number of dims shown is now:", event.value)
viewer = Viewer()
viewer.dims.events.ndim.connect(my_callback)
Viewer events#
Event |
Description |
Event.value type |
---|---|---|
|
Center of rotation for the camera. In 2D viewing the last two values are used. |
|
|
Scale from canvas pixels to world pixels. |
|
|
Euler angles of camera in 3D viewing (rx, ry, rz), in degrees. Only used during 3D viewing. Note that Euler angles’s intrinsic degeneracy means different sets of Euler angles may lead to the same view. |
|
|
Perspective (aka “field of view” in vispy) of the camera (if 3D). |
|
|
If the camera interactive panning with the mouse is enabled or not. |
|
|
If the camera interactive zooming with the mouse is enabled or not. |
|
|
Position of the cursor in world coordinates. None if outside the world. |
|
|
Flag to indicate whether cursor size should be scaled to zoom. Only relevant for circle and square cursors which are drawn with a particular size. |
|
|
Style of the cursor. Must be one of * square: A square * circle: A circle * cross: A cross * forbidden: A forbidden symbol * pointing: A finger for pointing * standard: The standard cursor # crosshair: A crosshair |
|
|
Size of the cursor in canvas pixels. Only relevant for circle and square cursors which are drawn with a particular size. |
|
|
Number of dimensions. |
|
|
Number of displayed dimensions. |
|
|
Tuple of ordering the dimensions, where the last dimensions are rendered. |
|
|
Tuple of labels for each dimension. |
|
|
Tuple of axis roll state. If True the axis is rollable. |
|
|
List of tuples (min, max, step), one for each dimension in world coordinates space. Lower and upper bounds are inclusive. |
|
|
Left margin in world pixels of the slice for each dimension. |
|
|
Right margin in world pixels of the slice for each dimension. |
|
|
Dims position in world coordinates for each dimension. |
|
|
Dimension which was last interacted with. |
|
|
Number of layers to place in each grid square before moving on to the next square. The default ordering is to place the most visible layer in the top left corner of the grid. A negative stride will cause the order in which the layers are placed in the grid to be reversed. |
|
|
Number of rows and columns in the grid. A value of -1 for either or both of will be used the row and column numbers will trigger an auto calculation of the necessary grid shape to appropriately fill all the layers at the appropriate stride. |
|
|
If grid is enabled or not. |
|
|
If tooltip is visible or not. |
|
|
text of tooltip |
|
|
|
|
|
|
|
|
|
|
|
The title of the viewer window. |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The title of the viewer window. By default ‘napari’. |
|
|
|
LayerList events#
Event |
Description |
Event.value type |
---|---|---|
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Layer events#
Events listed for the base class Layer
are present on all layer types.
Class |
Event |
Description |
Event.value type |
---|---|---|---|
|
|
source of the layer (such as a plugin or widget) |
|
|
|
Dimension names of the layer data. If not provided, axis_labels will be set to (…, ‘axis -2’, ‘axis -1’). |
|
|
|
Data that the layer is visualizing. Can be N-dimensional. |
|
|
|
Layer metadata. |
|
|
|
(N+1, N+1) affine transformation matrix in homogeneous coordinates. The first (N, N) entries correspond to a linear transform and the final column is a length N translation vector and a 1 or a napari |
|
|
|
One of a list of preset blending modes that determines how RGB and alpha values of the layer visual get mixed. Allowed values are {‘opaque’, ‘translucent’, ‘translucent_no_depth’, ‘additive’, and ‘minimum’}. |
|
|
|
String identifying which cursor displayed over canvas. |
|
|
|
Size of cursor if custom. None yields default size |
|
|
|
||
|
|
||
|
|
Displayed in status bar bottom right. |
|
|
|
||
|
|
||
|
|
Determine if canvas interactive panning is enabled with the mouse. |
|
|
|
Determine if canvas interactive zooming is enabled with the mouse. |
|
|
|
Name of the layer. If not provided then will be guessed using heuristics. |
|
|
|
Opacity of the layer visual, between 0.0 and 1.0. |
|
|
|
How data outside the viewed dimensions but inside the thick Dims slice will be projected onto the viewed dimensions. Must fit to cls._projectionclass. |
|
|
|
||
|
|
||
|
|
If a float convert into a 2D rotation matrix using that value as an angle. If 3-tuple convert into a 3D rotation matrix, using a yaw, pitch, roll convention. Otherwise assume an nD rotation. Angles are assumed to be in degrees. They can be converted from radians with np.degrees if needed. |
|
|
|
Scale factors for the layer. |
|
|
|
||
|
|
Either a vector of upper triangular values, or an nD shear matrix with ones along the main diagonal. |
|
|
|
Displayed in status bar bottom left. |
|
|
|
Array of thumbnail data for the layer. |
|
|
|
Translation values for the layer. |
|
|
|
Units of the layer data in world coordinates. If not provided, the default units are assumed to be pixels. |
|
|
|
Whether the layer visual is currently being displayed. |
|
|
|
Determine if canvas pan/zoom interactivity is enabled. This attribute is deprecated since 0.5.0 and should not be used. Use the mouse_pan and mouse_zoom attributes instead. |
|
|
|
||
|
|
||
|
|
Attenuation rate for attenuated maximum intensity projection. |
|
|
|
Convolution kernel used with the ‘custom’ interpolation mode in 2D rendering. |
|
|
|
3D Depiction mode. Must be one of {‘volume’, ‘plane’}. The default value is ‘volume’. |
|
|
|
||
|
|
Interpolation mode used by vispy for rendering 2d data. Must be one of our supported modes. (for list of supported modes see Interpolation enum) ‘custom’ is a special mode for 2D interpolation in which a regular grid of samples is taken from the texture around a position using ‘linear’ interpolation before being multiplied with a custom interpolation kernel (provided with ‘custom_interpolation_kernel_2d’). |
|
|
|
Same as ‘interpolation2d’ but for 3D rendering. |
|
|
|
Threshold for isosurface. |
|
|
|
Properties defining plane rendering in 3D. Properties are defined in data coordinates. Valid dictionary keys are {‘position’, ‘normal’, ‘thickness’, and ‘enabled’}. |
|
|
|
Rendering mode used by vispy. Must be one of our supported modes. |
|
|
|
Intensity value limits to be used for determining the minimum and maximum colormap bounds for luminance images. If not passed, they will be calculated as the min and max intensity value of the image. |
|
|
|
Range for the color limits for luminance images. If the image is rgb the contrast_limits_range is ignored. |
|
|
|
Gamma correction for determining colormap linearity; defaults to 1. |
|
|
|
Colormaps to use for luminance images. If a string, it can be the name of a supported colormap from vispy or matplotlib or the name of a vispy color or a hexadecimal RGB color representation. If a tuple, the first value must be a string to assign as a name to a colormap and the second item must be a Colormap. If a dict, the key must be a string to assign as a name to a colormap and the value must be a Colormap. |
|
|
|
||
|
|
Size of the paint brush in data coordinates. |
|
|
|
If |
|
|
|
If greater than 0, displays contours of labels instead of shaded regions with a thickness equal to its value. Must be >= 0. |
|
|
|
Features table where each row corresponds to a label and each column is a feature. The first row corresponds to the background label. |
|
|
|
Method for calulating the gradient (used to get the surface normal) in the ‘iso_categorical’ rendering mode. Must be one of {‘fast’, ‘smooth’}. ‘fast’ uses a simple finite difference gradient in x, y, and z. ‘smooth’ uses an isotropic Sobel gradient, which is smoother but more computationally expensive. The default value is ‘fast’. |
|
|
|
||
|
|
The number of dimensions across which labels will be edited. |
|
|
|
||
|
|
||
|
|
Properties for each label. Each property should be an array of length N, where N is the number of labels, and the first property corresponds to background. |
|
|
|
Index of selected label. Can be greater than the current maximum label. |
|
|
|
||
|
|
Size of the point marker in data pixels. If given as a scalar, all points are made the same size. If given as an array, size must be the same or broadcastable to the same shape as the data. |
|
|
|
Size of the marker for the next point to be added or the currently selected point. |
|
|
|
Width of the symbol border in pixels. |
|
|
|
Border width of the marker for the next point to be added or the currently selected point. |
|
|
|
If enabled, border_width is interpreted as a fraction of the point size. |
|
|
|
Color of the point marker body. Numeric color values should be RGB(A). |
|
|
|
Face color of the marker border for the next point to be added or the currently selected point. |
|
|
|
Color of the point marker border. Numeric color values should be RGB(A). |
|
|
|
Border color of the marker border for the next point to be added or the currently selected point. |
|
|
|
Properties for each point. Each property should be an array of length N, where N is the number of points. |
|
|
|
||
|
|
Symbols to be used for the point markers. Must be one of the following: arrow, clobber, cross, diamond, disc, hbar, ring, square, star, tailed_arrow, triangle_down, triangle_up, vbar, x. |
|
|
|
Symbol for the next point to be added or the currently selected points. |
|
|
|
If True, renders points not just in central plane but also slightly out of slice according to specified point marker size. |
|
|
|
This property will soon be deprecated in favor of ‘out_of_slice_display’. Use that instead. |
|
|
|
||
|
|
Render lighting and shading on points. Options are: * ‘none’ No shading is added to the points. * ‘spherical’ Shading and depth buffer are changed to give a 3D spherical look to the points |
|
|
|
||
|
|
Lower and upper limits for the size of points in canvas pixels. |
|
|
|
Features table where each row corresponds to a point and each column is a feature. |
|
|
|
The default value of each feature in a table with one row. |
|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
Multiplicative factor on projections for length of all vectors. |
|
|
|
Width for all vectors in pixels. |
|
|
|
Color of all of the vectors. |
|
|
|
One of a list of preset display modes that determines how vectors are displayed. Allowed values are {‘line’, ‘triangle’, and ‘arrow’}. |
|
|
|
||
|
|
Properties for each vector. Each property should be an array of length N, where N is the number of vectors. |
|
|
|
If True, renders vectors not just in central plane but also slightly out of slice according to specified point marker size. |
|
|
|
Features table where each row corresponds to a vector and each column is a feature. |
|
|
|
The default value of each feature in a table with one row. |
|
|
|
Thickness of lines and edges. If a list is supplied it must be the same length as the length of |
|
|
|
If string can be any color name recognized by vispy or hex value if starting with |
|
|
|
If string can be any color name recognized by vispy or hex value if starting with |
|
|
|
Properties for each shape. Each property should be an array of length N, where N is the number of shapes. |
|
|
|
Color of the edge of the next shape to be added or the currently selected shape. |
|
|
|
Color of the face of the next shape to be added or the currently selected shape. |
|
|
|
||
|
|
||
|
|
Features table where each row corresponds to a shape and each column is a feature. |
|
|
|
The default value of each feature in a table with one row. |
|
|
|
Color limits to be used for determining the colormap bounds for luminance images. If not passed is calculated as the min and max of the image. |
|
|
|
||
|
|
Gamma correction for determining colormap linearity. Defaults to 1. |
|
|
|
One of a list of preset shading modes that determine the lighting model using when rendering the surface in 3D. * |
|
|
|
Whether and how to display the edges of the surface mesh with a wireframe. |
|
|
|
Whether and how to display the face and vertex normals of the surface mesh. |
|
|
|
||
|
|
||
|
|
Features table where each row corresponds to a shape and each column is a feature. |
|
|
|
The default value of each feature in a table with one row. |
|
|
|
Width of the track tails in pixels. |
|
|
|
Length of the positive (backward in time) tails in units of time. |
|
|
|
Length of the positive (forward in time) tails in units of time. |
|
|
|
display the track id |
|
|
|
display the track tail |
|
|
|
display the graph edges |
|
|
|
Track property (from property keys) by which to color vertices. |
|
|
|
Default colormap to use to set vertex colors. Specialized colormaps, relating to specified properties can be passed to the layer via colormaps_dict. |
|
|
|
Properties for each point. Each property should be an array of length N, where N is the number of points. |
|
|
|
||
|
|