I have multiple sliders set up in dictionary.
Using a python callback function, i’d like to know which of the sliders has been changed - is this possible (or essentially, pass more than just the ‘value’)?
I tried creating a callback func for the gridplot object however that did not take me anywhere.
code below / thanks
from bokeh.io import show, output_notebook
output_notebook()
from bokeh.server.server import Server
from bokeh.application import Application
from bokeh.application.handlers.function import FunctionHandler
from bokeh.models.widgets import Slider
from bokeh.layouts import gridplot
def make_doc (doc):
sliders = {}
keys = ['a', 'b', 'c', 'd', 'e', 'g']
for i in keys:
sliders[i] = Slider (start=0, end=10, value=5, step=1, title=i)
def callback(attr, old, new):
print (new)
#how do i access other slider attributes here (e.g. 'title')?
for slider in sliders.values():
slider.on_change('value', callback)
#layout
sliderGrid = gridplot([i for i in sliders.values()], ncols=2)
doc.add_root(sliderGrid)
handler = FunctionHandler(make_doc)
app = Application(handler)
server = Server(app, port=5000)
server.start()
show(app)