Reputation: 2981
I would like to make an ipywidget floatslider, but passing it a list of values, rather than a range and step. Is there a way to do this, or is making a dropdown widget the only option?
Upvotes: 4
Views: 2035
Reputation: 2981
Woops! You can use SelectionSlider, e.g.:
import ipywidgets as widgets
def test(val):
print(val)
widgets.interact(test, val=widgets.SelectionSlider(description='value', options=['1', '50', '300', '7000']))
This widget wasn't available in my ipywidgets 4.0, so I had to upgrade. Also, make sure that afterward you run
jupyter nbextension enable --py --sys-prefix widgetsnbextension
as described in their installation instructions.
Upvotes: 6