Hi,
I have a code with a slider and a python function callback. The minimal version below models a much larger code where the callback function does an involved calculation, so don’t want to run the callback while the slider is moving. I’ve used callback_policy=‘mouseup’ but the callback continues to run even as the mouse is moving up and down the slider. This is not what I expect, but perhaps I misunderstand the usage of callback_policy. I tried callback_throttle with a long delay and that seems to have no effect either. Any advice?
Thanks
Jason
import numpy as np
from bokeh.plotting import Figure
from bokeh.models import ColumnDataSource
from bokeh.layouts import row, WidgetBox
from bokeh.models.widgets import Slider
from bokeh.io import curdoc
x = np.arange(101)/100.*3.
info = ColumnDataSource(data=dict(x=x, y=x*2.))
plot = Figure(plot_height=400, plot_width=800, title=" ",
tools="crosshair,pan,reset,resize,save,box_zoom,wheel_zoom",
x_range=[0.2, 3.0], y_range=[0, 100], toolbar_location='right')
plot.line(‘x’,‘y’,source=info,line_width=2.0, color=“green”, alpha=0.7)
time = Slider(title=“Time”, value=20., start=10., end=100.0, step=1.0, callback_policy=‘mouseup’)
def update_data(attrname, old, new):
print 'Updating model for time = ', time.value
x = np.arange(101)/100.*3.
info.data = dict(x=x, y=x*time.value)
time.on_change(‘value’, update_data)
inputs = WidgetBox(children=[time])
curdoc().add_root(row(children=[inputs, plot]))