##// END OF EJS Templates
Add an extended range abbreviation including a step value
Gordon Ball -
Show More
@@ -23,7 +23,7 b' from inspect import getcallargs'
23 from IPython.core.getipython import get_ipython
23 from IPython.core.getipython import get_ipython
24 from IPython.html.widgets import (Widget, TextWidget,
24 from IPython.html.widgets import (Widget, TextWidget,
25 FloatSliderWidget, IntSliderWidget, CheckboxWidget, DropdownWidget,
25 FloatSliderWidget, IntSliderWidget, CheckboxWidget, DropdownWidget,
26 ContainerWidget, DOMWidget, IntRangeSliderWidget)
26 ContainerWidget, DOMWidget, IntRangeSliderWidget, FloatRangeSliderWidget)
27 from IPython.display import display, clear_output
27 from IPython.display import display, clear_output
28 from IPython.utils.py3compat import string_types, unicode_type
28 from IPython.utils.py3compat import string_types, unicode_type
29 from IPython.utils.traitlets import HasTraits, Any, Unicode
29 from IPython.utils.traitlets import HasTraits, Any, Unicode
@@ -116,6 +116,17 b' def _widget_abbrev(o):'
116 else:
116 else:
117 cls = FloatRangeSliderWidget
117 cls = FloatRangeSliderWidget
118 return cls(value=(low, high), min=min, max=max)
118 return cls(value=(low, high), min=min, max=max)
119 elif _matches(o, [float_or_int]*5):
120 min, low, high, max, step = o
121 if not min <= low <= high <= max:
122 raise ValueError("Range input expects min <= low <= high <= max, got %r" % o)
123 if step <= 0:
124 raise ValueError("step must be >= 0, not %r" % step)
125 if all(isinstance(_, int) for _ in o):
126 cls = IntRangeSliderWidget
127 else:
128 cls = FloatRangeSliderWidget
129 return cls(value=(low, high), min=min, max=max, step=step)
119 else:
130 else:
120 return _widget_abbrev_single_value(o)
131 return _widget_abbrev_single_value(o)
121
132
General Comments 0
You need to be logged in to leave comments. Login now