Dropdown
selectors.Dropdown
Creates a Dropdown selector. Selection is limited to a predefined list of options.
| Parameter | Description | Default |
|---|---|---|
| selector_name | The name of the selector. It must be unique. | - |
| options | Options available for this selector. | - |
| options_names | Human readable counterpart of options. It will be str(options) if not defined. | - |
| label | The label for the selector. If not passed, the selector shows its selector_name. | - |
| default_value | If selected option is invalid or not defined, use this value. Must be the option name. | - |
| ignore_user_input | If passed True, picks default_value instead of the selected value. | False |
| run_on_change | If passed False the selector will not trigger execution on change. | True |
| placeholder | Short hint displayed in the input field before the user enters a value. | - |
| help_text | Tooltip help message displayed while the input is focused. | - |
| width | Custom selector width. | - |
| isDisabled | disable this selector. | False |
| block_uuid | Optional value to specify the block that will be executed when the selector triggers execution. | (current block uuid) |
Examples
sel = selectors.Dropdown("dropdown_0", options=['apple', 'pear'], options_names=['Apple', 'Pear'], label='Select a value')
sel.render()
print("You have selected", sel.value)
from IPython.display import display, HTML
elements =[]
options = ['foo', 'bar', 'zoooo', 'zaaa aa aar']
dropdown = selectors.Dropdown(
'dropdown-1',
options=options,
label='Drowpdown with helptext',
help_text='Custom help message',
)
elements.append(dropdown)
elements_html = "".join(
f'<tr><td>{element}</td><td>{element.value}</td></tr>'
for element in elements
)
display(HTML(f"""
<table>
<td></td><td>clicked</td>
{elements_html}
</table>
"""))
See also
- MultiDropdown — the multi-selection variant of this control.
- All selector types — the full catalog of available selector controls.
- Selectors — common arguments and how to define, render, and read selectors.