jupyter_bokeh icon indicating copy to clipboard operation
jupyter_bokeh copied to clipboard

RadioButton fires duplicate events on click

Open axil opened this issue 3 years ago • 3 comments

from jupyter_bokeh import BokehModel
from bokeh.models import RadioGroup

def update(event):
    print(event)

LABELS = ["Option 1", "Option 2", "Option 3"]

radio_group = RadioGroup(labels=LABELS, active=1)
radio_group.on_click(update)

BokehModel(radio_group)

After a click on "Option 3" it displays:

image

I would expect the event to be fired only once (in javascript it fires once).

axil avatar Jun 02 '22 10:06 axil

Does this happen only with BokehModel? If it happens in general, then this issue belongs in the main bokeh/bokeh repo.

bryevdv avatar Jun 02 '22 13:06 bryevdv

from bokeh.plotting import figure, show, curdoc
from bokeh.models import RadioGroup

def my_radio_handler(new):
    print('Radio button option ' + str(new) + ' selected.')

radio_group = RadioGroup(labels=["Option 1", "Option 2", "Option 3"], active=0)
radio_group.on_click(my_radio_handler)

curdoc().add_root(radio_group)
bokeh serve --show myapp.py

Single call.

axil avatar Jun 02 '22 16:06 axil

It turned out that all widgets are affected by this. I've made a quickfix. Plz have a look, @mattpap, maybe you'll find a better solution.

axil avatar Jul 07 '22 12:07 axil