--- a/wxglade_hmi/wxglade_hmi.py Wed Jun 13 08:54:13 2018 +0200
+++ b/wxglade_hmi/wxglade_hmi.py Fri Jun 15 09:48:05 2018 +0200
@@ -90,7 +90,10 @@
def CTNGenerate_C(self, buildpath, locations):
+ # list containing description of all objects declared in wxglade + # list containing only description of the main frame object wxgfile_path = self._getWXGLADEpath()
if os.path.exists(wxgfile_path):
@@ -100,12 +103,17 @@
for node in wxgtree.childNodes[1].childNodes:
if node.nodeType == wxgtree.ELEMENT_NODE:
- "name": node.getAttribute("name"),
+ name = node.getAttribute("name") + wxglade_object_desc = { "class": node.getAttribute("class"),
hnode.firstChild.data for hnode in
- node.getElementsByTagName("handler")]})
+ node.getElementsByTagName("handler")]} + hmi_objects.append(wxglade_object_desc) + if name == self.CTNName() : + main_frames.append(wxglade_object_desc) hmipyfile_path = os.path.join(self._getBuildPath(), "hmi.py")
if wx.Platform == '__WXMSW__':
@@ -122,12 +130,12 @@
- declare_hmi = "\n".join(["%(name)s = None\n" % x +
- "\n".join(["%(class)s.%(h)s = %(h)s" %
+ declare_hmi = "\n".join(["%(name)s = None\n" % x for x in main_frames]) + declare_hmi += "\n".join(["\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]) if len(hmi_frames) > 0 else "")
+ [x["name"] for x in main_frames]) if len(main_frames) > 0 else "") init_hmi = "\n".join(["""\
wx.MessageBox(_("Please stop PLC to close"))
@@ -135,10 +143,10 @@
%(name)s = %(class)s(None)
%(name)s.Bind(wx.EVT_CLOSE, OnCloseFrame)
-""" % x for x in hmi_frames])
+""" % x for x in main_frames]) ["if %(name)s is not None: %(name)s.Destroy()" % x
self.PreSectionsTexts = {
@@ -150,6 +158,11 @@
+ if len(main_frames) == 0 and \ + len(getattr(self.CodeFile, "start").getanyText().strip()) == 0: + self.GetCTRoot().logger.write_warning( + _("Warning: WxGlade HMI has no object with name identical to extension name, and no python code is provided in start section to create object.\n")) return PythonFileCTNMixin.CTNGenerate_C(self, buildpath, locations)