Fix validate logic if min/max are changed

This commit is contained in:
Gordon Ball 2014-07-03 12:05:49 +02:00
parent 1cb0cbf4b9
commit b7bb76f073
2 changed files with 10 additions and 6 deletions

View File

@ -78,9 +78,11 @@ class _BoundedFloatRangeWidget(_FloatRangeWidget):
"""Validate min <= low <= high <= max"""
if name == "value":
low, high = new
low = max(low, self.min)
high = min(high, self.max)
self.value = (min(low, high), max(low, high))
else:
low, high = self.value
low = max(low, self.min)
high = min(high, self.max)
self.value = (min(low, high), max(low, high))
class FloatRangeSliderWidget(_BoundedFloatRangeWidget):

View File

@ -77,9 +77,11 @@ class _BoundedIntRangeWidget(_IntRangeWidget):
"""Validate min <= low <= high <= max"""
if name == "value":
low, high = new
low = max(low, self.min)
high = min(high, self.max)
self.value = (min(low, high), max(low, high))
else:
low, high = self.value
low = max(low, self.min)
high = min(high, self.max)
self.value = (min(low, high), max(low, high))
class IntRangeSliderWidget(_BoundedIntRangeWidget):