Hi,
I was so hyped to see the update to callbacks in the recent update, and for the most part I grasped the concept. However, with the RadioGroup and RadioButtonGroup it doesn’t seem to work all the time.
I made a small example, that doens’t do what I’d expect it to:
from bokeh.plotting import show
from bokeh.io import output_notebook
from bokeh.layouts import column
from bokeh.models import CustomJS
from bokeh.models.widgets import Div, RadioButtonGroup, Button
output_notebook()
a = RadioButtonGroup(active = 0, labels=[‘one’,‘two’])
b = Div(text = ‘text’)
cb = CustomJS(args=dict(a=a,b=b),code = ‘’’
var val = a.get(‘active’)
var d = {
0:‘one’,
1:‘two’
}
var unitval = d[val]
b.set(‘text’,unitval);
b.trigger(‘change’);
‘’’)
c = Button(label=“Click here?”, button_type=“success”,callback=cb)
a.js_on_change(‘active’,cb)
show(column(a,b,c))
``
So, this code produces a radio button group with two buttons, and my hope was to trigger the callback by pressing the buttons, which should update the value of the Div text based on the button value (captured in ‘active’ field of the button group).
As a fallback option I also created a separate button with the same callback.
However, clicking either of the buttons doesn’t update the text field, and clicking the c button always updates the field to “one” regardless of the state of the radio group.
If I use RadioGroup instead, it seems to work in this example, but doesn’t work in a larger example I had, which is also super-strange…
Can anyone point me to extensive examples of callback usage with RadioButtons? Like, explaining what’s the difference between on_click, on_change, js_callbacks, js_on_click etc?