I want to have some sliders, and a button that resets them to default values. Currently the code looks like this:
xrange_slider = pn.widgets.RangeSlider(
name='X Range Slider', start=-10, end=+10, value=(-3, +3), step=0.01)
yrange_slider = pn.widgets.RangeSlider(
name='Y Range Slider', start=-10, end=+10, value=(-3, +3), step=0.01)
def reset_range_sliders(_event):
xrange_slider.value = (-3, +3)
yrange_slider.value = (-3, +3)
reset_button = pn.widgets.Button(
name='Reset ranges',
button_type='primary',
on_click=reset_range_sliders,
)
bound_plot = pn.bind(
plot, xrange_slider, yrange_slider
)
The problem is that when I move sliders, I get not one, but a few (lagged) updates.
However, when I tried to follow the recommendation in Enable Throttling subsection in _ Improve the Performance_ How-To, namely when I change the definition of bound_plot
to the following:
bound_plot = pn.bind(
plot, xrange_slider.param.value_throttled, yrange_slider.param.value_throttled
)
I got much smoother updates… but the reset_button
stopped working, and I was not able to enable it, and make it work again.
Could you please tell me how to force redraw of a specific panel.param.ParamFunction
?
I tried to use template.main[1].param.trigger('object')
inside on_click
function for reset_button
, but it did not work. This is different to the Is there a way to update value_throttled in slider through code/programmatically?, where setting value
made it work.
By the way, if it matters, the plot
function in question returns pn.pane.Matplotlib
.
Panel 1.5.2