##// END OF EJS Templates
Default to 25-75% of min-max if no value is set instead of 0-1
Gordon Ball -
Show More
@@ -70,8 +70,12 b' class _BoundedFloatRangeWidget(_FloatRangeWidget):'
70 min = CFloat(0.0, help="Min value", sync=True)
70 min = CFloat(0.0, help="Min value", sync=True)
71
71
72 def __init__(self, *pargs, **kwargs):
72 def __init__(self, *pargs, **kwargs):
73 """Constructor"""
73 set_value = 'value' not in kwargs
74 DOMWidget.__init__(self, *pargs, **kwargs)
74 DOMWidget.__init__(self, *pargs, **kwargs)
75 if set_value:
76 # if no value is set, use 25-75% to avoid the handles overlapping
77 self.value = (0.75*self.min + 0.25*self.max,
78 0.25*self.min + 0.75*self.max)
75 self.on_trait_change(self._validate, ['value', 'min', 'max'])
79 self.on_trait_change(self._validate, ['value', 'min', 'max'])
76
80
77 def _validate(self, name, old, new):
81 def _validate(self, name, old, new):
@@ -69,8 +69,12 b' class _BoundedIntRangeWidget(_IntRangeWidget):'
69 min = CInt(0, help="Min value", sync=True)
69 min = CInt(0, help="Min value", sync=True)
70
70
71 def __init__(self, *pargs, **kwargs):
71 def __init__(self, *pargs, **kwargs):
72 """Constructor"""
72 set_value = 'value' not in kwargs
73 DOMWidget.__init__(self, *pargs, **kwargs)
73 DOMWidget.__init__(self, *pargs, **kwargs)
74 if set_value:
75 # if no value is set, use 25-75% to avoid the handles overlapping
76 self.value = (0.75*self.min + 0.25*self.max,
77 0.25*self.min + 0.75*self.max)
74 self.on_trait_change(self._validate, ['value', 'min', 'max'])
78 self.on_trait_change(self._validate, ['value', 'min', 'max'])
75
79
76 def _validate(self, name, old, new):
80 def _validate(self, name, old, new):
General Comments 0
You need to be logged in to leave comments. Login now