
I would like to make two bokeh widgets talk to one another. I have a dropdown menu and a colorpicker. The aim is to show the color picker in a color according to my selection in the dropdown menu. I would like to get it to work in a jupyter notebook. I think I need to use CustomJS to handle a js event, but I am pretty sure I did it wrong. My aim is basically to update to push the selection in the dropdown menu into a variable “active_series” which I use to show the color.
Apoologies if this is a question answered many times, but I did not find an answer which worked for me.
Many thanks for your replies in advance
import bokeh
from bokeh import events
from bokeh.io import show, output_notebook, push_notebook
from bokeh.models.widgets import ColorPicker,Select
n_series=10
series_colours=bokeh.palettes.Category10_10
active_series='Series 1'
series={}
for i_series in range(n_series):
series['Series {:d}'.format(i_series+1)]=i_series
callback = CustomJS(args=dict(active_series=active_series), code="""
var active_series = cb_obj.value
active_series.change.emit();
""")
select = Select(title="Series",value=active_series, options=list(series.keys()), callback=callback2, width=200)
colorpicker = ColorPicker(color=series_colours[series[select.value]],title='Colour', width=50)
select.js_on_change('value', callback)
show(row(select, colorpicker))
'''

Works well!