msticpy.nbwidgets.select_item module

Module for pre-defined widget layouts.

class msticpy.nbwidgets.select_item.SelectItem(description: str = 'Select an item', options: List[str] | Dict[str, Any] | None = None, action: Callable[[...], Tuple | None] | None = None, value: str = '', **kwargs)

Bases: IPyDisplayMixin

Selection list from list or dict.

item_action

Action to call for each selection.

Type:

Callable[…, Optional[Tuple]]

Select an item from a list or dict.

Parameters:
  • description (str, optional) – The widget label to display. (the default is ‘Select an item’)

  • options (Union[List[str], Dict[str, Any]]) – Either: A list of items to select from (the default is None) A dict of items to select from. When using item_dict the values are displayed as the selectable items and key corresponding to the selected value is set as the value property.

  • action (Callable[..., Optional[Tuple[...]]], optional) – function to call when item selected (passed a single parameter - the value of the currently selected item) (the default is None). If the function returns one or a tuple of displayable objects these will be displayed.

  • value (str, optional) – A default value to pre-populate the filter with.

  • item_list (List[str], optional) – A list of items to select from (the default is None)

  • item_dict (Dict[str, str], optional) – A dict of items to select from. When using item_dict the keys are displayed as the selectable items and value corresponding to the selected key is set as the value property. (the default is None)

  • auto_display (bool, optional) – Whether to display on instantiation (the default is False)

  • height (str, optional) – Selection list height (the default is ‘100px’)

  • width (str, optional) – Selection list width (the default is ‘50%’)

  • display_filter (bool, optional) – Whether to display item filter (the default is True)

display()

Display the interactive widget.

property label

Return current display item.

property layout

Return underlying widget collection.

property value

Return the currently selected item.

class msticpy.nbwidgets.select_item.SelectString(*args, **kwargs)

Bases: SelectItem

Selection list from list or dict.

Deprecated since version 0.5.2: Superceded by SelectItem. Will be removed in v2.0.0.

Select an item from a list or dict.

Parameters:
  • description (str, optional) – The widget label to display. (the default is ‘Select an item’)

  • item_list (List[str], optional) – A list of items to select from (the default is None)

  • item_dict (Dict[str, str], optional) – A dict of items to select from. When using item_dict the keys are displayed as the selectable items and value corresponding to the selected key is set as the value property. (the default is None)

  • action (Callable[..., None], optional) – function to call when item selected (passed a single parameter - the value of the currently selected item) (the default is None)

  • auto_display (bool, optional) – Whether to display on instantiation (the default is False)

  • height (str, optional) – Selection list height (the default is ‘100px’)

  • width (str, optional) – Selection list width (the default is ‘50%’)

  • display_filter (bool, optional) – Whether to display item filter (the default is True)

display()

Display the interactive widget.

property label

Return current display item.

property layout

Return underlying widget collection.

property value

Return the currently selected item.