import panel as pn
pn.extension()
The Select
widget allows selecting a value
from a list or dictionary of options
by selecting it from a dropdown menu or selection area. It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup
, AutocompleteInput
and DiscreteSlider
widgets.
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.
For layout and styling related parameters see the customization user guide.
options
(list or dict): A list or dictionary of options to select fromsize
(int): Declares how many options are displayed at the same time. If set to 1 displays options as dropdown otherwise displays scrollable area.value
(object): The current value; must be one of the option valuesdisabled
(boolean): Whether the widget is editablename
(str): The title of the widgetselect = pn.widgets.Select(name='Select', options=['Biology', 'Chemistry', 'Physics'])
select
Like most other widgets, Select
has a value parameter that can be accessed or set:
select.value
Instead of a dropdown menu we can also select one option from a list by rendering multiple options at once using the size
parameter:
select_area = pn.widgets.Select(name='Select', options=['Biology', 'Chemistry', 'Physics'], size=3)
select_area
The Select
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(select.controls(jslink=True), select)