Merge pull request #791 from ExplodingCabbage/fix-intctrl-none-handling

Fix setting IntCtrl to None wrongly raising
This commit is contained in:
Robin Dunn
2018-03-21 19:36:03 -07:00
parent 62669d0f3e
commit a8d8c7ed90
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()