MultiChoice#

Download this notebook from GitHub (right-click to download).


import panel as pn
pn.extension()

The MultiChoice widget allows selecting multiple values from a list of options. It falls into the broad category of multi-value, option-selection widgets that provide a compatible API and include the MultiSelect, CrossSelector, CheckBoxGroup and CheckButtonGroup widgets. The MultiChoice widget provides a much more compact UI than MultiSelect.

For more information about listening to widget events and laying out widgets refer to the widgets user guide. Alternatively you can learn how to build GUIs by declaring parameters independently of any specific widgets in the param user guide. To express interactivity entirely using Javascript without the need for a Python server take a look at the links user guide.

Parameters:#

For layout and styling related parameters see the customization user guide.

Core#

  • options (list or dict): List or dictionary of options

  • max_items (int): Maximum number of options that can be selected

  • value (list): Currently selected option values

Display#

  • delete_button (boolean): Whether to display a button to delete a selected option

  • disabled (boolean): Whether the widget is editable

  • name (str): The title of the widget

  • option_limit (int): Maximum number of options to display at once.

  • search_option_limit (int): Maximum number of options to display at once if search string is entered.

  • placeholder (str): String displayed when no selection has been made.

  • solid (boolean): Whether to display widget with solid or light style.


multi_choice = pn.widgets.MultiChoice(name='MultiSelect', value=['Apple', 'Pear'],
    options=['Apple', 'Banana', 'Pear', 'Strawberry'])

pn.Column(multi_choice, height=200)

MultiChoice.value returns a list of the currently selected options:

multi_choice.value
['Apple', 'Pear']

The solid option controls the style of the widget:

pn.Column(multi_choice.clone(solid=False), height=200)

Controls#

The MultiChoice widget exposes a number of options which can be changed from both Python and Javascript. Try out the effect of these parameters interactively:

pn.Row(multi_choice.controls(jslink=True), multi_choice)
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).