Hi friends!
I want use custom validators in my app to check where input data correct or disallow it. With following example is not possible to check if input is correct or not, it just allow all input, even I explicitly point to use only float input???
import wx
import re
NUMBER = r'\d+$'
FLOAT = r'\d+(\.\d{1,2})?$'
class Validator(wx.PyValidator):
def __init__(self, regex=None):
wx.PyValidator.__init__(self)
self.regex = regex
if self.regex:
self.re = re.compile(regex)
def Clone(self):
return Validator(self.regex)
def Validate(self, win):
if not self.regex:
return True
window = self.GetWindow()
text = window.GetValue().strip()
if self.re.match(text):
return True
else:
return False
def TransferToWindow(self):
return true
def TransferFromWindow(self):
return true
Other way is to use OnChar method, but how I can check where inputed char fit appropriate regex, i.e is it float?
Thanks!