napari_track_edit.application_menus.layer_dropdown

Classes

LayerDropdown

QComboBox widget with functions for updating the selected layer and to update the

Module Contents

class napari_track_edit.application_menus.layer_dropdown.LayerDropdown(viewer: napari.Viewer, layer_types: tuple, allow_none=False, exclude_types: tuple = (), follow_active: bool = True)

Bases: qtpy.QtWidgets.QComboBox

QComboBox widget with functions for updating the selected layer and to update the list of options when the list of layers is modified.

Parameters:
  • viewer (napari.Viewer) – the viewer whose layers are listed.

  • layer_types (tuple) – the layer types to list.

  • allow_none (bool) – whether to add a ‘No selection’ entry. Defaults to False.

  • exclude_types (tuple) – layer types to leave out of the list.

  • follow_active (bool) – when True (the default), the dropdown follows the active layer in the viewer. Set to False to only change the selection when the user explicitly picks a layer from the dropdown.

layer_changed
viewer
layer_types
exclude_types = ()
allow_none = False
follow_active = True
selected_layer = None
_deleted = False
_rename_callbacks: dict[int, tuple[weakref.ref, callable]]
_watch_name(layer) → bool

Start tracking name changes of this layer, if it is one we list.

Returns:

True if the layer is listed (and is now watched), False otherwise.

_make_weak_rename_cb()

Create a weak callback to track name updates but do not let the layer keep the widget alive forever.

_on_insert(event) → None

Update dropdown and make new layer responsive to name changes

_on_removed(event) → None

Disconnect signals and update dropdown when a layer is removed.

_on_selection_changed()

Update the active layer when the selection changes

_update_dropdown(event=None) → None

Update the layers in the dropdown

set_layer_types(layer_types: tuple, exclude_types: tuple = ()) → None

Change which layer types are listed (and which to exclude) and refresh.

_emit_layer_changed() → None

Emit a signal holding the currently selected layer

_on_destroyed(*args)

Disconnect everything cleanly