from bokeh.models.widgets import Select from bokeh.layouts import row from bokeh.plotting import curdoc # defining options for the select widget options = ['Option 1', 'Option 2', 'Option 3'] # creating a select widget select_widget = Select(title='Select an option:', value=options[0], options=options) # displaying select widget curdoc().add_root(row(select_widget))
from bokeh.models.widgets import Select from bokeh.layouts import column from bokeh.plotting import curdoc # defining options for the select widget options = ['Option 1', 'Option 2', 'Option 3'] # function to display selected option def display_selection(attr, old, new): print(f'Selected option: {new}') # creating a select widget select_widget = Select(title='Select an option:', value=options[0], options=options) # custom callback function for the select widget select_widget.on_change('value', display_selection) # displaying select widget curdoc().add_root(column(select_widget))Both the above examples use the Bokeh library package for the `Select` widget.