2329
|
1 |
#!/usr/bin/env python
|
|
2 |
# -*- coding: utf-8 -*-
|
|
3 |
|
|
4 |
# See COPYING file for copyrights details.
|
|
5 |
|
|
6 |
from __future__ import absolute_import
|
|
7 |
|
|
8 |
from itertools import repeat, izip_longest
|
|
9 |
import wx
|
|
10 |
|
|
11 |
class SchemeEditor(wx.Panel):
|
|
12 |
def __init__(self, scheme, parent, *args, **kwargs):
|
|
13 |
self.txtctrls = {}
|
|
14 |
wx.Panel.__init__(self, parent, *args, **kwargs)
|
|
15 |
|
|
16 |
self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10)
|
|
17 |
|
|
18 |
for tag, label in self.model:
|
|
19 |
txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1))
|
|
20 |
self.txtctrls[tag] = txtctrl
|
|
21 |
for win, flag in [
|
|
22 |
(wx.StaticText(self, label=label), wx.ALIGN_CENTER_VERTICAL),
|
|
23 |
(txtctrl, wx.GROW)]:
|
|
24 |
self.mainSizer.AddWindow(win, flag=flag)
|
|
25 |
|
|
26 |
self.mainSizer.AddSpacer(20)
|
|
27 |
|
|
28 |
self.SetSizer(self.mainSizer)
|
|
29 |
|
|
30 |
def SetFields(self, fields):
|
|
31 |
for tag, label in self.model:
|
|
32 |
self.txtctrls[tag].SetValue(fields[tag])
|
|
33 |
|
|
34 |
def GetFields(self):
|
|
35 |
return {tag: self.txtctrls[tag].GetValue() for tag,label in self.model}
|
|
36 |
|