-
Notifications
You must be signed in to change notification settings - Fork 0
/
validators.py
68 lines (53 loc) · 1.66 KB
/
validators.py
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import wx
"""
Validators for the wizard
"""
class TextNotEmptyValidator(wx.PyValidator):
"""
Have we entered a title?
error label is a wx.StaticText on the wizard page
"""
def __init__(self, error_label):
wx.PyValidator.__init__(self)
self.error_label = error_label
def Clone(self):
return TextNotEmptyValidator(self.error_label)
def Validate(self, win):
textCtrl = self.GetWindow()
text = textCtrl.GetValue()
if not text:
self.error_label.SetLabel('***Please enter a title***')
textCtrl.SetFocus()
textCtrl.GetParent().Refresh()
return False
else:
self.error_label.SetLabel('')
return True
def TransferToWindow(self):
return True
def TransferFromWindow(self):
return True
class ResultsListNotEmptyValidator(wx.PyValidator):
"""
Have we selected a results file?
"""
def __init__(self, error_label):
wx.PyValidator.__init__(self)
self.error_label = error_label
def Clone(self):
return ResultsListNotEmptyValidator(self.error_label)
def Validate(self, win):
results_list = self.GetWindow()
results_count = results_list.GetCount()
if not results_count:
self.error_label.SetLabel('***Please select at least one results file***')
results_list.SetFocus()
results_list.GetParent().Refresh()
return False
else:
self.error_label.SetLabel('')
return True
def TransferToWindow(self):
return True
def TransferFromWindow(self):
return True