def Validate(self, win):
tc = self.GetWindow()
val = tc.GetValue()
nm = tc.GetName()
try:
v = self.func(val)
if self.flag and v <= 0.0:
wx.MessageBox("%s must be positive" % nm, "Error")
elif v < 0.0:
wx.MessageBox("%s must be non-negative" % nm, "Error")
else:
tc.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_WINDOW))
tc.Refresh()
return True
except ValueError:
wx.MessageBox("%s is not a valid number" % nm, "Error")
tc.SetBackgroundColour("YELLOW")
tc.Clear()
tc.SetFocus()
tc.Refresh()
return False
评论列表
文章目录