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 |
---|---|---|
|
If axes are visible or not. |
|
|
If axes labels are visible or not. Not the actual axes labels are stored in |
|
|
If axes are colored or not. If colored then default coloring is x=cyan, y=yellow, z=magenta. If not colored than axes are the color opposite of the canvas background. |
|
|
If axes are dashed or not. If not dashed then all the axes are solid. If dashed then x=solid, y=dashed, z=dotted. |
|
|
If axes have arrowheads or not. |
|
|
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 interactivity 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. |
|
|
Size of the cursor in canvas pixels.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 |
|
|
Number of dimensions. |
|
|
Number of displayed dimensions. |
|
|
Dimension which was last used. |
|
|
List of tuples (min, max, step), one for each dimension. In a world coordinates space. As with Python’s |
|
|
Tuple of the slider position for each dims slider, in slider coordinates. |
|
|
Tuple of ordering the dimensions, where the last dimensions are rendered. |
|
|
Tuple of labels for each dimension. |
|
|
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 scale bar is visible or not. |
|
|
If scale bar are colored or not. If colored then default color is magenta. If not colored than scale bar color is the opposite of the canvas background or the background box. |
|
|
Scalebar and text color. See |
|
|
If scale bar has ticks at ends or not. |
|
|
Position of the scale bar in the canvas. Must be one of ‘top left’, ‘top right’, ‘bottom right’, ‘bottom left’. Default value is ‘bottom right’. |
|
|
The font size (in points) of the text. |
|
|
If background box is visible or not. |
|
|
Background box color. See |
|
|
Unit to be used by the scale bar. The value can be set to |
|
|
If text overlay is visible or not. |
|
|
A (4,) color array of the text overlay. |
|
|
The font size (in points) of the text. |
|
|
Position of the text overlay in the canvas. Must be one of ‘top left’, ‘top right’, ‘top center’, ‘bottom right’, ‘bottom left’, ‘bottom_center’. Default value is ‘top left’ |
|
|
Text to be displayed in the canvas. |
|
|
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) |
|
|
|
||
|
|
||
|
|
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’, and ‘additive’}. |
|
|
|
Opacity of the layer visual, between 0.0 and 1.0. |
|
|
|
Whether the layer visual is currently being displayed. |
|
|
|
Scale factors for the layer. |
|
|
|
Translation values for the layer. |
|
|
|
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. |
|
|
|
Either a vector of upper triangular values, or an nD shear matrix with ones along the main diagonal. |
|
|
|
(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 |
|
|
|
||
|
|
Name of the layer. |
|
|
|
Array of thumbnail data for the layer. |
|
|
|
Displayed in status bar bottom left. |
|
|
|
Displayed in status bar bottom right. |
|
|
|
Determine if canvas pan/zoom interactivity is enabled. |
|
|
|
String identifying which cursor displayed over canvas. |
|
|
|
Size of cursor if custom. None yields default size |
|
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
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. |
|
|
|
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. |
|
|
|
Colormap to use for luminance images. If a string must be the name of a supported colormap from vispy or matplotlib. 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. |
|
|
|
Interactive mode. The normal, default mode is PAN_ZOOM, which allows for normal interactivity with the canvas. In TRANSFORM mode the image can be transformed interactively. |
|
|
|
Interpolation mode used by vispy. Must be one of our supported modes. |
|
|
|
||
|
|
||
|
|
Rendering mode used by vispy. Must be one of our supported modes. |
|
|
|
3D Depiction mode. Must be one of {‘volume’, ‘plane’}. The default value is ‘volume’. |
|
|
|
Threshold for isosurface. |
|
|
|
Attenuation rate for attenuated maximum intensity projection. |
|
|
|
||
|
|
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. |
|
|
|
The number of dimensions across which labels will be edited. |
|
|
|
If |
|
|
|
Size of the paint brush in data coordinates. |
|
|
|
Index of selected label. Can be greater than the current maximum label. |
|
|
|
||
|
|
||
|
|
If greater than 0, displays contours of labels instead of shaded regions with a thickness equal to its value. |
|
|
|
Features table where each row corresponds to a label and each column is a feature. The first row corresponds to the background label. |
|
|
|
||
|
|
Interactive mode. The normal, default mode is PAN_ZOOM, which allows for normal interactivity with the canvas. In ADD mode clicks of the cursor add points at the clicked location. In SELECT mode the cursor can select points by clicking on them or by dragging a box around them. Once selected points can be moved, have their properties edited, or be deleted. |
|
|
|
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. |
|
|
|
Width of the symbol edge in pixels. |
|
|
|
If enabled, edge_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 edge 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). |
|
|
|
Edge color of the marker edge 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. |
|
|
|
||
|
|
Symbol 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. |
|
|
|
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. |
|
|
|
Stores 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. |
|
|
|
||
|
|
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. |
|
|
|
Stores the default value of each feature in a table with one row. |
|
|
|
Interactive mode. The normal, default mode is PAN_ZOOM, which allows for normal interactivity with the canvas. The SELECT mode allows for entire shapes to be selected, moved and resized. The DIRECT mode allows for shapes to be selected and their individual vertices to be moved. The VERTEX_INSERT and VERTEX_REMOVE modes allow for individual vertices either to be added to or removed from shapes that are already selected. Note that shapes cannot be selected in this mode. The ADD_RECTANGLE, ADD_ELLIPSE, ADD_LINE, ADD_PATH, and ADD_POLYGON modes all allow for their corresponding shape type to be added. |
|
|
|
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. |
|
|
|
Stores the default value of each feature in a table with one row. |
|
|
|
One of a list of preset shading modes that determine the lighting model using when rendering the surface in 3D. * |
|
|
|
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. |
|
|
|
||
|
|