from IPython.html.widgets import *
from IPython.display import display
a = IntSlider(description='Test')
display(a)
print a.value
## displays 20 instead of 50. Although the slider visually is at 50
What is happening is, the value is set from the Javascript side on change of min. This is happening not necessarily before the value is set on the python side in the next statement.
I was able to avoid the issue by setting the value on the min_changed function on the python side and not updating it from JS.
def _handle_min_changed(self, name, old, new):
"""Make sure the max is always >= the min and change value if needed."""
if new > self.max:
raise ValueError("setting min > max")
if self.value < self.min:
self.value = self.min
What do you guys think will be the best way to deal with this?
Thanks,
Srinivas
What is happening is, the value is set from the Javascript side on change of min. This is happening not necessarily before the value is set on the python side in the next statement.
I was able to avoid the issue by setting the value on the min_changed function on the python side and not updating it from JS.
What do you guys think will be the best way to deal with this?
Thanks,
Srinivas