Is there a way to update value_throttled in slider through code/programmatically?

I’m using the value_throttled attribute of pn.widgets.RangeSlider() for callbacks in my app and it’s great for my heavy calculation updates: it waits until the button release to trigger the update. However I can’t set any value for value_throttled programmatically, which I would really appreciate as I’d like a reset button to reset all my sliders.

Setting it directly is not allowed myslider.value_throttled = 5 gives me a:

TypeError: Constant parameter ‘value_throttled’ cannot be modified

But updating the myslider.value = 5 leaves the value_throttled untouched, see gif below.

How can I use value_throttled and still update the value through code?

I think the Intentions of value_throttled is to only be used in pn.depends, pn.bind or pn.interact to delay the action of the slider until the release of the mouse and then use actual value inside the function.

For the reset you could properly set the value back to default and call the function which depends on the value_throttled. If this is not possible (by design of your app) there is a way to change value_throttled itself, but this can leave to bad side effects.

Thanks for your quick reply. Using the .value instead works!
For the reset button, I now update the value attribute, which resets the sliders and call my callback function explicitly. This is actually an improvement, as the callback isn’t triggered every time I reset a single slider!

1 Like