1
#Boa:Dialog:MaskedEditFormatCodesDlg
4
from wx.lib.anchors import LayoutAnchors
10
('R', 'Right-align field(s)'),
11
('r', 'Right-insert in field(s) (implies R)'),
12
('<', 'Stay in field until explicit navigation out of it'),
13
('>', 'Allow insert/delete within partially filled fields'),
14
(',', 'Allow comma to be typed as grouping character; auto-group/regroup digits in\ninteger fields (if result fits) when leaving such a field.'),
15
('-', 'Prepend and reserve leading space for sign to mask and allow signed values (negative #s shown in red by default)'),
16
('0', 'integer fields get leading zeros'),
17
('D', 'Date[/time] field'),
19
('F', 'Auto-Fit: the control calulates its size from the length of the template mask'),
20
('V', 'Validate entered chars against ValidRegex, blocking invalid characters'),
21
('S', 'select entire field when navigating to new field'),
24
[wxID_MASKEDEDITFORMATCODESDLG, wxID_MASKEDEDITFORMATCODESDLGBTNCANCEL,
25
wxID_MASKEDEDITFORMATCODESDLGBTNOK,
26
wxID_MASKEDEDITFORMATCODESDLGCLBFORMATCODES,
27
wxID_MASKEDEDITFORMATCODESDLGSTATICTEXT1,
28
wxID_MASKEDEDITFORMATCODESDLGTCFORMATCODEPROPVAL,
29
] = [wx.NewId() for _init_ctrls in range(6)]
31
class MaskedEditFormatCodesDlg(wx.Dialog):
32
def _init_ctrls(self, prnt):
33
# generated method, don't edit
34
wx.Dialog.__init__(self, id=wxID_MASKEDEDITFORMATCODESDLG,
35
name='MaskedEditFormatCodesDlg', parent=prnt, pos=wx.Point(433,
36
218), size=wx.Size(436, 399),
37
style=wx.RESIZE_BORDER | wx.DEFAULT_DIALOG_STYLE,
38
title='Masked Edit - Format Codes')
39
self.SetClientSize(wx.Size(428, 372))
40
self.SetAutoLayout(True)
43
self.clbFormatCodes =wx.CheckListBox(choices=[],
44
id=wxID_MASKEDEDITFORMATCODESDLGCLBFORMATCODES,
45
name='clbFormatCodes', parent=self, pos=wx.Point(8, 33),
46
size=wx.Size(413, 258), style=wx.LB_HSCROLL | wx.LB_SINGLE)
47
self.clbFormatCodes.SetConstraints(LayoutAnchors(self.clbFormatCodes,
48
True, True, True, True))
49
self.clbFormatCodes.Bind(wx.EVT_CHECKLISTBOX, self.OnClbformatcodesChecklistbox, id=wxID_MASKEDEDITFORMATCODESDLGCLBFORMATCODES)
51
self.tcFormatCodePropVal =wx.TextCtrl(id=wxID_MASKEDEDITFORMATCODESDLGTCFORMATCODEPROPVAL,
52
name='tcFormatCodePropVal', parent=self, pos=wx.Point(8, 299),
53
size=wx.Size(413, 25), style=0, value=self.formatCode)
54
self.tcFormatCodePropVal.SetConstraints(LayoutAnchors(self.tcFormatCodePropVal,
55
True, False, True, True))
57
self.btnOK =wx.Button(id=wx.ID_OK, label='OK', name='btnOK', parent=self,
58
pos=wx.Point(261, 340), size=wx.Size(75, 23), style=0)
59
self.btnOK.SetConstraints(LayoutAnchors(self.btnOK, False, False, True,
62
self.btnCancel =wx.Button(id=wx.ID_CANCEL, label='Cancel',
63
name='btnCancel', parent=self, pos=wx.Point(346, 340),
64
size=wx.Size(75, 23), style=0)
65
self.btnCancel.SetConstraints(LayoutAnchors(self.btnCancel, False,
68
self.staticText1 =wx.StaticText(id=wxID_MASKEDEDITFORMATCODESDLGSTATICTEXT1,
69
label='A string of formatting codes that modify behavior of the control.',
70
name='staticText1', parent=self, pos=wx.Point(8, 5),
71
size=wx.Size(409, 24), style=wx.NO_BORDER | wx.ST_NO_AUTORESIZE)
72
self.staticText1.SetConstraints(LayoutAnchors(self.staticText1, True,
75
def __init__(self, parent, formatCode=''):
77
self.formatCode = formatCode
79
self._init_ctrls(parent)
81
if wx.Platform == '__WXGTK__': fontSize = 13
84
self.clbFormatCodes.SetFont(wx.Font(fontSize, wx.MODERN, wx.NORMAL, wx.BOLD))
85
self.tcFormatCodePropVal.SetFont(wx.Font(fontSize+1, wx.MODERN, wx.NORMAL, wx.BOLD))
87
for fc, desc in formatCodes:
90
fmtCode = ' %s '%fmtCode
92
self.clbFormatCodes.Append('%s - %s'%(fmtCode, desc))
93
if formatCode.find(fc) != -1:
94
self.clbFormatCodes.Check(self.clbFormatCodes.GetCount()-1, True)
96
self.rebuildFmtCodePropVal()
98
def rebuildFmtCodePropVal(self):
100
for idx in range(self.clbFormatCodes.GetCount()):
101
if self.clbFormatCodes.IsChecked(idx):
102
r.append(formatCodes[idx][0])
104
self.tcFormatCodePropVal.SetValue(''.join(r))
106
def getFormatCode(self):
107
return self.tcFormatCodePropVal.GetValue()
109
def OnClbformatcodesChecklistbox(self, event):
110
self.rebuildFmtCodePropVal()
114
if __name__ == '__main__':
115
app =wx.PySimpleApp()
116
wx.InitAllImageHandlers()
117
dlg = MaskedEditFormatCodesDlg(None, 'F_,-')