Creating widgets to add interactivity to plots
One of Bokeh's most unique features is the ability to add widgets that add interactivity to plots. Widgets allow the user of the plot to change what they want to see by making selections, clicking on buttons, and typing into textboxes. In this section, you will learn about all the widgets that Bokeh can add to your Toolbelt.
The two imports that you will need to create and output any kind of widget are given here:
from bokeh.io import output_file, show from bokeh.layouts import widgetbox
Creating a button widget
Buttons allow a user to click and make a selection. We can create a button widget in Bokeh by using the code shown here:
#Import the required packages from bokeh.models.widgets import Button #Create the button widget button_widget = Button(label="Click this") #Output the button output_file("button_widget.html") show(widgetbox(button_widget))
This will create a button as illustrated in the diagram here:

In this code, we used the Button...