Skip to content Skip to sidebar Skip to footer

How To Perform An Onclick Action On Button Click In Python Bokeh?

I'm new to bokeh and I have aquery regarding button onclick event, the code is provided below: x = widgetbox(button) show(x) fruits = ['Answered', 'Unanswered','Total']

Solution 1:

You must assign the callback to the button like this:

from bokeh.models import Button
from bokeh.io import curdoc

bt = Button(label='Click me')

defchange_click():
    print('I was clicked')

bt.on_click(change_click)

curdoc().add_root(bt)

Launch this with bokeh serve --show example.py.

Note: Also take a look at my question where I talk about dynamic layout

Post a Comment for "How To Perform An Onclick Action On Button Click In Python Bokeh?"