-
-
Notifications
You must be signed in to change notification settings - Fork 530
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting slider value programmatically does not update value_throttled parameter #2675
Comments
Has anyone found a solution to this problem? I am struggling with this... As far as I can tell, it is not possible to change the value_throttled parameter manually either because it is defined as constant? |
If you are using def make_plot(arg1):
real_value = slider.value # instead of arg1 which may not be up to date
...
dmap = hv.DynamicMap(pn.bind(make_plot, arg1=slider.param.value_throttled)) |
I want to be able to set the throttled slider value from a different callback in the code, e.g. from a button press. button_handler(event): This fails with an error saying that value_throttled is a constant parameter. I can change the 'value' parameter, but the problem is that I have a dynamic map relying on the throttled value. So changing slider.value from the button-press will not update the dynamic map... |
My suggestion is setting |
Thanks @hoxbro In my case this does not help though. In fact I'm populating the slider's options dynamically which leads to some subtle but harmful behavior: slider.options = ['A', 'B', 'C']
slider.value = 'B'
# User plays around with the slider and then loads some other data, which will update the options
slider.options = ['D', 'E', 'F']
slider.value = 'E'
# Here, value will be 'E' but value_throttled will remain whatever it was before among the previous options
# User changes value from 'E' to 'D' but the DynamicMap is not updated The problem lies with the fact that when you change the options while I guess one solution would be to instantiate a new slider instead of updating the existing instance but that's not ideal for me. Another would be to always initialize the slider to the first value but it will not be appropriate in some situations. |
panel 0.12.1
param 1.11.1
bokeh 2.3.3
This is a continuation of #1256.
When changing the
value
parameter of a slider from python after instantiation,value_throttled
is not updated. Then it's only when the user changes the slider value in the browser that the discrepancy betweenvalue_throttled
andvalue
disappears. I think all sliders are affected.For instance with a FloatSlider, if you have the following:
you will get 0 instead of 1.
This can have detrimental consequences, because if the slider
value
is changed based on some event, you cannot reliably make things depend on thevalue_throttled
parameter, which can be at odds withvalue
and with the state of the widget as displayed in the browser.Because of this, there are situations where you can't use
value_throttled
when it's needed, for instance as arguments of a DynamicMap when you have high computational costs associated with a change of parameters.The text was updated successfully, but these errors were encountered: