From 51dc53fd1e6865e014cea9c720271e61aff6fc56 2014-08-07 19:32:25 From: Gordon Ball Date: 2014-08-07 19:32:25 Subject: [PATCH] Default to 25-75% of min-max if no value is set instead of 0-1 --- diff --git a/IPython/html/widgets/widget_float.py b/IPython/html/widgets/widget_float.py index cc55d9d..0c68f44 100644 --- a/IPython/html/widgets/widget_float.py +++ b/IPython/html/widgets/widget_float.py @@ -70,8 +70,12 @@ class _BoundedFloatRangeWidget(_FloatRangeWidget): min = CFloat(0.0, help="Min value", sync=True) def __init__(self, *pargs, **kwargs): - """Constructor""" + set_value = 'value' not in kwargs DOMWidget.__init__(self, *pargs, **kwargs) + if set_value: + # if no value is set, use 25-75% to avoid the handles overlapping + self.value = (0.75*self.min + 0.25*self.max, + 0.25*self.min + 0.75*self.max) self.on_trait_change(self._validate, ['value', 'min', 'max']) def _validate(self, name, old, new): diff --git a/IPython/html/widgets/widget_int.py b/IPython/html/widgets/widget_int.py index ec8648f..cb2a712 100644 --- a/IPython/html/widgets/widget_int.py +++ b/IPython/html/widgets/widget_int.py @@ -69,8 +69,12 @@ class _BoundedIntRangeWidget(_IntRangeWidget): min = CInt(0, help="Min value", sync=True) def __init__(self, *pargs, **kwargs): - """Constructor""" + set_value = 'value' not in kwargs DOMWidget.__init__(self, *pargs, **kwargs) + if set_value: + # if no value is set, use 25-75% to avoid the handles overlapping + self.value = (0.75*self.min + 0.25*self.max, + 0.25*self.min + 0.75*self.max) self.on_trait_change(self._validate, ['value', 'min', 'max']) def _validate(self, name, old, new):