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 |
8 from itertools import repeat, izip_longest |
|
9 from functools import partial |
9 import wx |
10 import wx |
|
11 |
|
12 from controls.IDManager import IDManager |
10 |
13 |
11 class SchemeEditor(wx.Panel): |
14 class SchemeEditor(wx.Panel): |
12 def __init__(self, scheme, parent, *args, **kwargs): |
15 def __init__(self, scheme, parent, *args, **kwargs): |
13 self.txtctrls = {} |
16 self.txtctrls = {} |
14 wx.Panel.__init__(self, parent, *args, **kwargs) |
17 wx.Panel.__init__(self, parent, *args, **kwargs) |
15 |
18 |
16 self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10) |
19 self.fieldsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=10) |
|
20 |
|
21 if self.EnableIDSelector: |
|
22 self.model = self.model + [("ID", _("ID:"))] |
17 |
23 |
18 for tag, label in self.model: |
24 for tag, label in self.model: |
19 txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1)) |
25 txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1)) |
20 self.txtctrls[tag] = txtctrl |
26 self.txtctrls[tag] = txtctrl |
21 for win, flag in [ |
27 for win, flag in [ |
22 (wx.StaticText(self, label=label), wx.ALIGN_CENTER_VERTICAL), |
28 (wx.StaticText(self, label=label), wx.ALIGN_CENTER_VERTICAL), |
23 (txtctrl, wx.GROW)]: |
29 (txtctrl, wx.GROW)]: |
24 self.mainSizer.AddWindow(win, flag=flag) |
30 self.fieldsizer.AddWindow(win, flag=flag) |
25 |
31 |
26 self.mainSizer.AddSpacer(20) |
32 self.fieldsizer.AddSpacer(20) |
27 |
33 |
28 self.SetSizer(self.mainSizer) |
34 if self.EnableIDSelector: |
|
35 self.mainsizer = wx.FlexGridSizer(cols=2, hgap=10, vgap=10) |
|
36 self.mainsizer.AddSizer(self.fieldsizer) |
|
37 self.idselector = IDManager( |
|
38 self, parent.ctr, |
|
39 partial(wx.CallAfter, parent.SetURI)) |
|
40 self.mainsizer.AddWindow(self.idselector) |
|
41 self.SetSizer(self.mainsizer) |
|
42 else: |
|
43 self.SetSizer(self.fieldsizer) |
29 |
44 |
30 def SetFields(self, fields): |
45 def SetFields(self, fields): |
31 for tag, label in self.model: |
46 for tag, label in self.model: |
32 self.txtctrls[tag].SetValue(fields[tag]) |
47 self.txtctrls[tag].SetValue(fields[tag]) |
33 |
48 |