diff --git a/unittests/test_lib_intctrl.py b/unittests/test_lib_intctrl.py index 027101a6..34fba200 100644 --- a/unittests/test_lib_intctrl.py +++ b/unittests/test_lib_intctrl.py @@ -15,6 +15,13 @@ class IntCtrlTests(wtc.WidgetTestCase): t3.ChangeValue(16) self.assertTrue(not t3.IsInBounds()) + def test_canSetValueToNone(self): + t1 = IC.IntCtrl(self.frame, allow_none=True, value=None) + assert t1.GetValue() is None + t2 = IC.IntCtrl(self.frame, allow_none=True) + t2.SetValue(None) + assert t2.GetValue() is None + #--------------------------------------------------------------------------- diff --git a/wx/lib/intctrl.py b/wx/lib/intctrl.py index 51d44e0d..08633e1a 100644 --- a/wx/lib/intctrl.py +++ b/wx/lib/intctrl.py @@ -804,10 +804,10 @@ class IntCtrl(wx.TextCtrl): Colors text with oob_color if current value exceeds bounds set for control. """ - if not self.IsInBounds(value): - self.SetForegroundColour(self.__oob_color) - else: + if value is None or self.IsInBounds(value): self.SetForegroundColour(self.__default_color) + else: + self.SetForegroundColour(self.__oob_color) self.Refresh()