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
indexinserted (index (int, value: T)) – emitted after
valueis inserted atindexremoving (index (int)) – emitted before an item is removed at
indexremoved (index (int, value: T)) – emitted after
valueis removed atindexmoving (index (int, new_index: int)) – emitted before an item is moved from
indextonew_indexmoved (index (int, new_index: int, value: T)) – emitted after
valueis moved fromindextonew_indexchanged (index (int, old_value: T, value: T)) – emitted when item at
indexis changed fromold_valuetovaluechanged <OVERLOAD> (index (slice, old_value: List[_T], value: List[_T])) – emitted when item at
indexis changed fromold_valuetovaluereordered (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)
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
valuebefore index.move(src_index[, dest_index])Insert object at
src_indexbeforedest_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 items from list.
reverse()Reverse list IN PLACE.
Select all items in the list.
select_next([step, shift])Selects next item from list.
select_previous([shift])Selects previous item from list.
Attributes
Get current selection.
Details
- append(value)#
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S#
- copy() TypedMutableSequence[_T]#
Return a shallow copy of the list.
- count(value) integer -- return number of occurrences of value#
- extend(values)#
S.extend(iterable) – extend sequence by appending elements from the iterable
- index(value: _L, start: int = 0, stop: int | None = None) int#
Return first index of value.
- Parameters:
value (Any) – A value to lookup. If type(value) is in the lookups functions provided for this class, then values in the list will be searched using the corresponding lookup converter function.
start (int, optional) – The starting index to search, by default 0
stop (int, optional) – The ending index to search, by default None
- Returns:
The index of the value
- Return type:
- Raises:
ValueError – If the value is not present
- move(src_index: int, dest_index: int = 0) bool#
Insert object at
src_indexbeforedest_index.Both indices refer to the list prior to any object removal (pre-move space).
- move_multiple(sources: Iterable[int | slice], dest_index: int = 0) int#
Move a batch of sources indices, to a single destination.
Note, if dest_index is higher than any of the sources, then the resulting position of the moved objects after the move operation is complete will be lower than dest_index.
- Parameters:
dest_index (int, optional) – The destination index. All sources will be inserted before this index (in pre-move space), by default 0… which has the effect of “bringing to front” everything in
sources, or acting as a “reorder” method ifsourcescontains all indices.
- Returns:
The number of successful move operations completed.
- Return type:
- Raises:
TypeError – If the destination index is a slice, or any of the source indices are not
intorslice.
- 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.
- pop([index]) item -- remove and return item at index (default last).#
Raise IndexError if list is empty or index is out of range.
- remove(value)#
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.