hscommon.gui.selectable_list — dupeGuru 4.0.4 documentation

# dupeGuru 4.0.4 documentation

## hscommon.gui.selectable_list

`Selectable`() | Mix-in for a `Sequence` that manages its selection status.
`SelectableList`([items]) | A list that can manage selection of its items.
`GUISelectableList`([items]) | Cross-toolkit GUI-enabled list view.
`GUISelectableListView` | Expected interface for `GUISelectableList`’s view.

class `hscommon.gui.selectable_list.` `Selectable`

  Mix-in for a `Sequence` that manages its selection status.

  When mixed in with a `Sequence`, we enable it to manage its selection status. The selection is held as a list of `int` indexes. Multiple selection is supported.

  `_update_selection`()

    (Virtual) Updates the model’s selection appropriately.

    Called after selection has been updated. Takes the table’s selection and does appropriates updates on the view and/or model. Common sense would dictate that when the selection doesn’t change, we don’t update anything (and thus don’t call `_update_selection()` at all), but there are cases where it’s false. For example, if our list updates its items but doesn’t change its selection, we probably want to update the model’s selection.

    By default, does nothing.

    Important note: This is only called on `select()`, not on changes to `selected_indexes`.

  `select`(indexes)

    Update selection to `indexes`.

    `_update_selection()` is called afterwards.

    Parameters

      indexes (list) – List of `int` that is to become the new selection.

  property `selected_index`

    Points to the first selected index.

    int. get/set.

    Thin wrapper around `selected_indexes`. `None` if selection is empty. Using this property only makes sense if your selectable sequence supports single selection only.

  property `selected_indexes`

    List of selected indexes.

    list of int. get/set.

    When setting the value, automatically removes out-of-bounds indexes. The list is kept sorted.

class `hscommon.gui.selectable_list.` `SelectableList`(items=None)

  A list that can manage selection of its items.

  Subclasses `Selectable`. Behaves like a `list`.

  `_on_change`()

    (Virtual) Called whenever the contents of the list changes.

    By default, does nothing.

  `append`(item)

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

  `insert`(index, item)

    S.insert(index, value) – insert value before index

  `remove`(row)

    S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.

class `hscommon.gui.selectable_list.` `GUISelectableList`(items=None)

  Cross-toolkit GUI-enabled list view.

  Represents a UI element presenting the user with a selectable list of items.

  Subclasses `SelectableList` and `GUIObject`. Expected view: `GUISelectableListView`.

  Parameters

    items (iterable) – If specified, items to fill the list with initially.

  `_on_change`()

    Refreshes the view contents with `GUISelectableListView.refresh()`.

    Overrides `SelectableList._on_change()`.

  `_update_selection`()

    Refreshes the view selection with `GUISelectableListView.update_selection()`.

    Overrides `Selectable._update_selection()`.

  `_view_updated`()

    Refreshes the view contents with `GUISelectableListView.refresh()`.

    Overrides `_view_updated()`.

class `hscommon.gui.selectable_list.` `GUISelectableListView`

  Expected interface for `GUISelectableList`’s view.

  Not actually used in the code. For documentation purposes only.

  Our view, some kind of list view or combobox, is expected to sync with the list’s contents by appropriately behave to all callbacks in this interface.

  `refresh`()

    Refreshes the contents of the list widget.

    Ensures that the contents of the list widget is synced with the model.

  `update_selection`()

    Update selection status.

    Ensures that the list widget’s selection is in sync with the model.