Fix setting IntCtrl to None wrongly raising

This commit is contained in:
Mark Amery
2018-03-16 12:35:38 +00:00
parent 4a90db1c3b
commit 1e1c4356c4
2 changed files with 10 additions and 3 deletions

View File

@@ -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
#---------------------------------------------------------------------------

View File

@@ -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()