3

我想做一个ipywidget floatslider,但传递一个值列表,而不是范围和步骤。有没有办法做到这一点,或者让下拉小部件成为唯一的选择?

4

1 回答 1

5

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.

于 2016-09-09T15:44:29.437 回答