AutocompleteInput#

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


import panel as pn
pn.extension()

The AutocompleteInput widget allows selecting a value from a list or dictionary of options by entering the value into an auto-completing text field. It falls into the broad category of single-value, option-selection widgets that provide a compatible API and include the RadioBoxGroup, Select 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.

Parameters:#

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

Core#

  • options (list): A list of options to select from

  • restrict (boolean): Set to False in order to allow users to enter text that is not present in the options list.

  • value (str): The current value updated when pressing key; must be one of the option values if restrict=True.

  • value_input (str): The current value updated on every key press.

  • case_sensitive (boolean): Enable or disable case sensitivity for matching completions.

Display#

  • disabled (boolean): Whether the widget is editable

  • name (str): The title of the widget

  • placeholder (str): A placeholder string displayed when no option is selected

  • min_characters (int): The number of characters a user must type before completions are presented.


autocomplete = pn.widgets.AutocompleteInput(
    name='Autocomplete Input', options=['Biology', 'Chemistry', 'Physics'],
    placeholder='Write something here')

pn.Row(autocomplete, height=100)

Like most other widgets, AutocompleteInput has a value parameter that can be accessed or set:

autocomplete.value
''

If restrict=False the AutocompleteInput will allow any input in addition to the completions it offers:

not_restricted = autocomplete.clone(value='Mathematics', restrict=False)
pn.Row(not_restricted, height=100)
not_restricted.value
'Mathematics'

Controls#

The AutocompleteInput 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(autocomplete.controls(jslink=True), autocomplete)
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).