浏览代码

wxGUI: FloatValidator - skip empty strings

git-svn-id: https://svn.osgeo.org/grass/grass/trunk@42335 15284696-431f-4ddb-bdfa-cd5b030d7da7
Martin Landa 15 年之前
父节点
当前提交
89f189a10d
共有 1 个文件被更改,包括 12 次插入9 次删除
  1. 12 9
      gui/wxpython/gui_modules/menuform.py

+ 12 - 9
gui/wxpython/gui_modules/menuform.py

@@ -2095,16 +2095,19 @@ class FloatValidator(wx.PyValidator):
         """Validate input"""
         textCtrl = self.GetWindow()
         text = textCtrl.GetValue()
-        try:
-            float(text)
-        except ValueError:
-            textCtrl.SetBackgroundColour("grey")
-            textCtrl.SetFocus()
-            textCtrl.Refresh()
-            return False
+
+        if text:
+            try:
+                float(text)
+            except ValueError:
+                textCtrl.SetBackgroundColour("grey")
+                textCtrl.SetFocus()
+                textCtrl.Refresh()
+                return False
+        
+        sysColor = wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)
+        textCtrl.SetBackgroundColour(sysColor)
         
-        textCtrl.SetBackgroundColour(
-            wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW))
         textCtrl.Refresh()
         
         return True