ViewerSelect#

class jdaviz.core.template_mixin.ViewerSelect(**kwargs: Any)[source]#

Bases: SelectPluginComponent

Plugin select for viewers, with support for single or multi-selection.

Useful API methods/attributes:

Traitlets (in the object, custom traitlets in the plugin):

  • items (list of dicts with keys: id, reference, label)

  • selected (string)

Properties (in the object only):

  • ids (list of ids corresponding to items)

  • references (list of references corresponding to items)

  • labels (list of references falling back on ids corresponding to items. These

    are the values seen in the dropdown, although setting either id or reference to the traitlet will still process correctly)

  • selected_item (dict of the currently selected entry in items)

  • selected_id (string corresponding to the id of selected_item)

  • selected_obj (viewer item corresponding to selected)

To use in a plugin:

  • create traitlets with default values

  • register with all the automatic logic in the plugin’s init by passing the string names of the respective traitlets

  • use component in plugin template (see below)

  • refer to properties above based on the interally stored reference to the instantiated object of this component

Example template (label and hint are optional):

<plugin-viewer-select
  :items="viewer_items"
  :selected.sync="viewer_selected"
  label="Viewer"
  hint="Select viewer."
/>

This extends BasePluginComponent for common functionality for a select/dropdown component. The subclasses MUST have an items traitlet as a list of dictionaries, with ‘label’ as the selection entry (and any other optional entries for styling, etc) and a selected string traitlet. The subclasses should also override selected_obj and may choose to override _selected_changed (likely with a super call to keep the base logic).

Attributes Summary

ids

references

selected_id

selected_obj

selected_reference

Methods Summary

add_filter(*filters)

Attributes Documentation

ids#
references#
selected_id#
selected_obj#
selected_reference#

Methods Documentation

add_filter(*filters)[source]#