Edouard@2329: #!/usr/bin/env python Edouard@2329: # -*- coding: utf-8 -*- Edouard@2329: Edouard@2329: # See COPYING file for copyrights details. Edouard@2329: Edouard@2329: from __future__ import absolute_import Edouard@2329: Edouard@2329: from itertools import repeat, izip_longest Edouard@2329: import wx Edouard@2329: Edouard@2329: class SchemeEditor(wx.Panel): Edouard@2329: def __init__(self, scheme, parent, *args, **kwargs): Edouard@2329: self.txtctrls = {} Edouard@2329: wx.Panel.__init__(self, parent, *args, **kwargs) Edouard@2329: Edouard@2329: self.mainSizer = wx.FlexGridSizer(cols=2, hgap=10, rows=5, vgap=10) Edouard@2329: Edouard@2329: for tag, label in self.model: Edouard@2329: txtctrl = wx.TextCtrl(parent=self, size=wx.Size(200, -1)) Edouard@2329: self.txtctrls[tag] = txtctrl Edouard@2329: for win, flag in [ Edouard@2329: (wx.StaticText(self, label=label), wx.ALIGN_CENTER_VERTICAL), Edouard@2329: (txtctrl, wx.GROW)]: Edouard@2329: self.mainSizer.AddWindow(win, flag=flag) Edouard@2329: Edouard@2329: self.mainSizer.AddSpacer(20) Edouard@2329: Edouard@2329: self.SetSizer(self.mainSizer) Edouard@2329: Edouard@2329: def SetFields(self, fields): Edouard@2329: for tag, label in self.model: Edouard@2329: self.txtctrls[tag].SetValue(fields[tag]) Edouard@2329: Edouard@2329: def GetFields(self): Edouard@2329: return {tag: self.txtctrls[tag].GetValue() for tag,label in self.model} Edouard@2329: