32 lines
781 B
Python
32 lines
781 B
Python
import wx
|
|
import string
|
|
|
|
class DataValidator(wx.PyValidator):
|
|
def __init__(self):
|
|
wx.PyValidator.__init__(self)
|
|
self.flag = flag
|
|
self.Bind(wx.EVT_CHAR, self.OnChar)
|
|
|
|
def clone(self):
|
|
return DataValidator()
|
|
|
|
def validate(self):
|
|
return True
|
|
|
|
def TransferToWindow(self):
|
|
return True
|
|
|
|
def TransferFromWindow(self):
|
|
return True
|
|
|
|
def OnChar(self, event):
|
|
keycode = int(event.GetKeyCode())
|
|
if keycode < 256:
|
|
#print keycode
|
|
key = chr(keycode)
|
|
#print key
|
|
if self.flag == 'no-alpha' and key in string.ascii_letters:
|
|
return
|
|
if self.flag == 'no-digit' and key in string.digits:
|
|
return
|
|
event.Skip() |