Callback_policy="mouseup" doesn't works as expected

Hi,

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
regards

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<source.data['y_2'].length; i++) {
    source.data['y_2'][i] = source.data['y'][i] + this.value[0];  //  lower bound from RangeSlider
};
source.change.emit();
''')

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")

col = column(p, range_slider)
show(col)

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.

2 Likes

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?
regards

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

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 !!!
regards