3 |
3 |
4 # See COPYING file for copyrights details. |
4 # See COPYING file for copyrights details. |
5 |
5 |
6 from __future__ import absolute_import |
6 from __future__ import absolute_import |
7 |
7 |
8 from itertools import repeat, izip_longest |
|
9 from functools import partial |
8 from functools import partial |
10 import wx |
9 import wx |
11 |
10 |
12 from controls.IDBrowser import IDBrowser |
11 from controls.IDBrowser import IDBrowser |
13 |
12 |
|
13 |
14 class SchemeEditor(wx.Panel): |
14 class SchemeEditor(wx.Panel): |
15 def __init__(self, scheme, parent, *args, **kwargs): |
15 def __init__(self, scheme, parent, *args, **kwargs): |
16 self.txtctrls = {} |
16 self.txtctrls = {} |
17 wx.Panel.__init__(self, parent, *args, **kwargs) |
17 wx.Panel.__init__(self, parent, *args, **kwargs) |
18 |
18 |
19 self.fieldsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=10) |
19 self.fieldsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=10) |
20 |
20 |
21 if self.EnableIDSelector: |
21 if self.EnableIDSelector: |
23 |
23 |
24 for tag, label in self.model: |
24 for tag, label in self.model: |
25 txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1)) |
25 txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1)) |
26 self.txtctrls[tag] = txtctrl |
26 self.txtctrls[tag] = txtctrl |
27 for win, flag in [ |
27 for win, flag in [ |
28 (wx.StaticText(self, label=label), wx.ALIGN_CENTER_VERTICAL), |
28 (wx.StaticText(self, label=label), |
29 (txtctrl, wx.GROW)]: |
29 wx.ALIGN_CENTER_VERTICAL), |
|
30 (txtctrl, wx.GROW)]: |
30 self.fieldsizer.AddWindow(win, flag=flag) |
31 self.fieldsizer.AddWindow(win, flag=flag) |
31 |
32 |
32 self.fieldsizer.AddSpacer(20) |
33 self.fieldsizer.AddSpacer(20) |
33 |
34 |
34 if self.EnableIDSelector: |
35 if self.EnableIDSelector: |
43 self.SetSizer(self.mainsizer) |
44 self.SetSizer(self.mainsizer) |
44 else: |
45 else: |
45 self.SetSizer(self.fieldsizer) |
46 self.SetSizer(self.fieldsizer) |
46 |
47 |
47 def SetFields(self, fields): |
48 def SetFields(self, fields): |
48 for tag, label in self.model: |
49 for tag, _label in self.model: |
49 self.txtctrls[tag].SetValue(fields[tag]) |
50 self.txtctrls[tag].SetValue(fields[tag]) |
50 |
51 |
51 def GetFields(self): |
52 def GetFields(self): |
52 return {tag: self.txtctrls[tag].GetValue() for tag,label in self.model} |
53 return {tag: self.txtctrls[tag].GetValue() for tag, _label in self.model} |
53 |
|