napari.utils.events.SelectableEventedList#

class napari.utils.events.SelectableEventedList(*args: Any, **kwargs: Any)[source]#

Bases: Selectable[_T], EventedList[_T]

List model that also supports selection.

Events:
  • inserting (index (int)) – emitted before an item is inserted at index
    • inserted (index (int, value: T)) – emitted after value is inserted at index

    • removing (index (int)) – emitted before an item is removed at index

    • removed (index (int, value: T)) – emitted after value is removed at index

    • moving (index (int, new_index: int)) – emitted before an item is moved from index to new_index

    • moved (index (int, new_index: int, value: T)) – emitted after value is moved from index to new_index

    • changed (index (int, old_value: T, value: T)) – emitted when item at index is changed from old_value to value

    • changed <OVERLOAD> (index (slice, old_value: List[_T], value: List[_T])) – emitted when item at index is changed from old_value to value

    • reordered (value (self)) – emitted when the list is reordered (eg. moved/reversed).

    • selection.changed (added (Set[_T], removed: Set[_T])) – Emitted when the set changes, includes item(s) that have been added and/or removed from the set.

    • selection.active (value (_T)) – emitted when the current item has changed.

    • selection._current (value (_T)) – emitted when the current item has changed. (Private event)

inherited-members:

Methods

append(value)

S.append(value) -- append value to the end of the sequence

clear()

copy()

Return a shallow copy of the list.

count(value)

extend(values)

S.extend(iterable) -- extend sequence by appending elements from the iterable

index(value[, start, stop])

Return first index of value.

insert(index, value)

Insert value before index.

move(src_index[, dest_index])

Insert object at src_index before dest_index.

move_multiple(sources[, dest_index])

Move a batch of sources indices, to a single destination.

move_selected(index, insert)

Reorder list by moving the item at index and inserting it at the insert index.

pop([index])

Raise IndexError if list is empty or index is out of range.

remove(value)

S.remove(value) -- remove first occurrence of value.

remove_selected()

Remove selected items from list.

reverse()

Reverse list IN PLACE.

select_all()

Select all items in the list.

select_next([step, shift])

Selects next item from list.

select_previous([shift])

Selects previous item from list.

Attributes

selection

Get current selection.

Details

insert(index: int, value: _T) None[source]#

Insert value before index.

move_selected(index: int, insert: int) None[source]#

Reorder list by moving the item at index and inserting it at the insert index. If additional items are selected these will get inserted at the insert index too. This allows for rearranging the list based on dragging and dropping a selection of items, where index is the index of the primary item being dragged, and insert is the index of the drop location, and the selection indicates if multiple items are being dragged. If the moved layer is not selected select it.

This method is deprecated. Please use layers.move_multiple with layers.selection instead.

Parameters:
  • index (int) – Index of primary item to be moved

  • insert (int) – Index that item(s) will be inserted at

remove_selected() None[source]#

Remove selected items from list.

select_all() None[source]#

Select all items in the list.

select_next(step: int = 1, shift: bool = False) None[source]#

Selects next item from list.

select_previous(shift: bool = False) None[source]#

Selects previous item from list.