--- a/wxglade_hmi/wxglade_hmi.py Thu May 16 14:46:20 2013 +0900
+++ b/wxglade_hmi/wxglade_hmi.py Thu May 16 14:47:57 2013 +0900
@@ -39,7 +39,7 @@
def CTNGenerate_C(self, buildpath, locations):
wxgfile_path=self._getWXGLADEpath()
if os.path.exists(wxgfile_path):
@@ -49,7 +49,12 @@
for node in wxgtree.childNodes[1].childNodes:
if node.nodeType == wxgtree.ELEMENT_NODE:
- hmi_frames[node._attrs["name"].value] = node._attrs["class"].value
+ "name" : node.getAttribute("name"), + "class" : node.getAttribute("class"), + hnode.firstChild.data for hnode in + node.getElementsByTagName("handler")]}) hmipyfile_path=os.path.join(self._getBuildPath(), "hmi.py")
if wx.Platform == '__WXMSW__':
@@ -63,25 +68,31 @@
define_hmi = hmipyfile.read().decode('utf-8')
- declare_hmi = "\n".join(map(lambda x:"%s = None" % x,
- global_hmi = "global "+",".join(hmi_frames.keys()) + "\n"
- init_hmi = "\n".join(map(lambda x: """\
+ declare_hmi = "\n".join(["%(name)s = None\n" % x + + "\n".join(["%(class)s.%(h)s = %(h)s"% + dict(x,h=h) for h in x['handlers']]) + global_hmi = "global %s\n"%",".join( + [x["name"] for x in hmi_frames]) + init_hmi = "\n".join(["""\ wx.MessageBox(_("Please stop PLC to close"))
%(name)s = %(class)s(None)
%(name)s.Bind(wx.EVT_CLOSE, OnCloseFrame)
-""" % {"name": x[0], "class": x[1]}, hmi_frames.items()))
- cleanup_hmi = "\n".join(map(lambda x:"if %s is not None: %s.Destroy()" % (x,x), hmi_frames.keys()))
+""" % x for x in hmi_frames]) + cleanup_hmi = "\n".join( + ["if %(name)s is not None: %(name)s.Destroy()" % x self.PreSectionsTexts = {
- "globals":define_hmi + declare_hmi,
"stop":global_hmi + cleanup_hmi
self.PostSectionsTexts = {