from bokeh.models.widgets import Select options = ['Option 1', 'Option 2', 'Option 3'] select = Select(title='Select Option', options=options) # Show the widget layout = column(select) show(layout)
from bokeh.models.widgets import Select from bokeh.plotting import figure, show options = ['Option 1', 'Option 2', 'Option 3'] select = Select(title='Select Option', options=options) # Create a plot plot = figure() # Callback function to update plot based on selected option def update_plot(attr, old, new): plot.title.text = new # Bind callback function to the widget's value property select.on_change('value', update_plot) # Add widget and plot to layout layout = column(select, plot) # Show the widget and plot show(layout)This code creates a `Select` widget with three options (`Option 1`, `Option 2`, and `Option 3`) and a title of `Select Option`. We then create a `plot` using Bokeh's `figure` function. We create a `update_plot` function that will update the plot's title based on the selected option, and bind that function to the `Select` widget's `value` property using `on_change`. Finally, we add the `Select` widget and the `plot` to a `column` layout and display it using `show`. Package library: Bokeh.