In jupyter,I have the following code to create a slider control for my variable r using ipywidgets.
from ipywidgets import interact, interactive, fixed, interact_manual
import ipywidgets as widgets
r = 0.9992
def sl(r=0.9992):
global ar
ar = r
interact(sl, r=(0.999, 1, 0.0001))
It works but the problem is that the display of slider value is rounded to 2 decimal. As a result, the display always show 1.00.
Is there any way to display its actual value?
Since the version 6.x of ipywidgets, FloatSlider
contains readout_format
attribute. Just set it to your desired precision, e.g. like this:
widgets.FloatSlider(value=7.5, min=0, max=10.0,
step=0.001, readout_format='.3f')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With