How to use the napari.viewer.Viewer.bind_key function in napari

To help you get started, we’ve selected a few napari examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Control-T')
def transpose_axes(viewer):
    """Transpose order of the last two visible axes, e.g. [0, 1] -> [1, 0]."""
    viewer.dims._transpose()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Control-A')
def select_all(viewer):
    """Selected all layers."""
    viewer.layers.select_all()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Alt-Down')
def focus_axes_down(viewer):
    """Move focus of dimensions slider down."""
    viewer.window.qt_viewer.dims.focus_down()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Up')
def select_layer_above(viewer):
    """Select layer above."""
    viewer.layers.select_next()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Shift-Down')
def also_select_layer_below(viewer):
    """Also select layer below."""
    viewer.layers.select_previous(shift=True)
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Right')
def increment_dims_right(viewer):
    """Increment dimensions slider to the right."""
    axis = viewer.window.qt_viewer.dims.last_used
    if axis is not None:
        cur_point = viewer.dims.point[axis]
        axis_range = viewer.dims.range[axis]
        new_point = np.clip(
            cur_point + axis_range[2],
            axis_range[0],
            axis_range[1] - axis_range[2],
        )
        viewer.dims.set_point(axis, new_point)
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Control-Y')
def toggle_ndisplay(viewer):
    """Toggle ndisplay."""
    if viewer.dims.ndisplay == 3:
        viewer.dims.ndisplay = 2
    else:
        viewer.dims.ndisplay = 3
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Alt-Up')
def focus_axes_up(viewer):
    """Move focus of dimensions slider up."""
    viewer.window.qt_viewer.dims.focus_up()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Control-G')
def toggle_grid(viewer):
    """Toggle grid mode."""
    if np.all(viewer.grid_size == (1, 1)):
        viewer.grid_view()
    else:
        viewer.stack_view()
github napari / napari / napari / keybindings.py View on Github external
@Viewer.bind_key('Control-Backspace')
def remove_selected(viewer):
    """Remove selected layers."""
    viewer.layers.remove_selected()