Callback_policy="mouseup" doesn't works as expected


callback_policy=“mouseup” doesn’t works as expected. It responds every steps of the rangeslider.

Here is the related code fragment:

callback = CustomJS(args=dict(...  ), code=code )

range_slider = RangeSlider(start=0.0, end=0.85, value=(0,0.85), step=0.01 , title="Deprem Tehlike Değeri",callback=callback, callback_policy="mouseup" )

what am I doing wrong

Hi ahmettemiz88,

It doesn’t look like anything in your code fragment is wrong. I worked up a little example with it to show the ‘mouseup’ callback_policy in action:

from bokeh.models import RangeSlider, CustomJS, ColumnDataSource
from bokeh.plotting import show, figure
from bokeh.layouts import column

p = figure(y_range=[0, 4])

cds = ColumnDataSource(data={
'x': [1, 2, 3, 4, 5, 6, 7, 8],
'y': [1, 2, 3, 2, 1, 2, 3, 2],
'y_2': [1, 2, 3, 2, 1, 2, 3, 2]

line_to_change = p.line(x='x', y='y_2', color='green', source=cds)

callback = CustomJS(args=dict(source=cds), code='''
for (i=0; i<['y_2'].length; i++) {['y_2'][i] =['y'][i] + this.value[0];  //  lower bound from RangeSlider

range_slider = RangeSlider(start=0.0, end=0.85, value=(0,0.85), step=0.01,
                       title="Deprem Tehlike Değeri", callback=callback,

col = column(p, range_slider)

If you move the lower end of the RangeSlider, you can see that the plot updates only when you drop the slider. (It’s not listening to the top end, so moving that won’t do anything. :slight_smile: )

If you’re still having trouble, I recommend posting a fully runnable minimal example with the behavior you’re seeing.

1 Like

Note that callback_policy will be removed in Bokeh 2.0. Instead use the properties value (every update) or value_throttled (throttled updates) to trigger callbacks.


Thank you ,
Is there any example code?
if I am not mistaken, python callback of slider leads to unnecessary processes until mouseup. Does value update bring a solution?

Thank you,
I updated my code as you have suggested.
It is OK now.

FYI for anyone else this change was described in the 1.2.0 release notes:

1 Like

Thank you,
THIS is mouseup for python callback !! improvement !!!