-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathvalidators.py
More file actions
42 lines (34 loc) · 1.16 KB
/
validators.py
File metadata and controls
42 lines (34 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import wx
import wx.grid
class numOnlyValidator(wx.Validator):
def __init__(self):
super(numOnlyValidator, self).__init__()
self.Bind(wx.EVT_CHAR, self.Validate)
# --------------------------------------------------------------------------
def Clone(self):
return numOnlyValidator()
# --------------------------------------------------------------------------
def Validate(self, event):
k = event.GetKeyCode()
if not(k >= 48 and k <= 57):
#wx.MessageBox("Please enter numbers only", "Invalid Input", wx.OK | wx.ICON_ERROR)
return False
#self.GetWindow().SetValue( self.GetWindow().GetValue() + chr(k) )
event.Skip()
return True
# --------------------------------------------------------------------------
def TransferToWindow(self):
return True
# --------------------------------------------------------------------------
def TransferFromWindow(self):
return True
'''
class numOnlyGridEditor (wx.grid.GridCellTextEditor):
def __init__ (self):
super(numOnlyGridEditor, self).__init__()
self.SetValidator(numOnlyValidator())
def EndEdit (self, row, col, grid, oldval):
print ("asdasd")
if not self.Validate():
return None
'''