import panel as pn pn.extension()
Panel provides a wide range of widgets to provide precise control over parameter values. The widget classes use a consistent API that allows treating broad categories of widgets as interchangeable. For instance, to select a value from a list of options, you can interchangeably use a
Select widget, a
RadioButtonGroup, or a range of other equivalent widgets.
Like all other components in
Widget objects will render and sync their state both in the notebook and on Bokeh server:
widget = pn.widgets.TextInput(name='A widget', value='A string') widget
Changing the text value will automatically update the corresponding parameter, if you have a live running Python process:
Updating the parameter value will also update the widget:
widget.value = 'ABCDEFG'
Laying out widgets#
To compose multiple widgets they can be added to a
Tabs Panel. To learn more about laying out widgets and panels, see the customization user guide.
slider = pn.widgets.FloatSlider(name='Another widget', width=200) pn.Column(widget, slider, width=200)
Types of Widgets#
The supported widgets can be grouped into a number of distinct categories with compatible APIs.
Option selector widgets allow selecting one or more values from a list or dictionary. All widgets of this type have
These widgets allow selecting one value from a list or dictionary of options:
AutocompleteInput: Select a
valueby entering it into an auto-completing text field.
DiscretePlayer: Displays media-player-like controls which allow playing and stepping through the provided options.
DiscreteSlider: Select a value using a slider.
RadioButtonGroup: Select a value from a set of mutually exclusive toggle buttons.
RadioBoxGroup: Select a value from a set of mutually exclusive checkboxes.
Select: Select a value using a dropdown menu.
These widgets allow selecting multiple values from a list or dictionary of options:
Type-based selectors provide means to select a value according to its type, and all have a
value. The widgets in this category may also have other forms of validation beyond the type, e.g. the upper and lower bounds of sliders.
Allow selecting a single
value of the appropriate type:
Numeric selectors are bounded by a
Allow selecting a range of values of the appropriate type stored as a
(lower, upper) tuple on the
DateRangeSlider: Select a date range using a slider with two handles.
Button: Allows triggering events when the button is clicked. Unlike other widgets, it does not have a
DataFrame: A widget that allows displaying and editing a Pandas DataFrame.
FileDownload: A button that allows downloading a file on the frontend by sending the file data to the browser.