Fixed bug in wxGlade extension when compiling and starting project with no hmi defined
authorLaurent Bessard
Thu, 13 Jun 2013 09:42:59 +0200
changeset 1256 02a710c7b5ed
parent 1255 ff59c6a8b793
child 1257 4b7ef7ea318f
Fixed bug in wxGlade extension when compiling and starting project with no hmi defined
wxglade_hmi/wxglade_hmi.py
--- a/wxglade_hmi/wxglade_hmi.py	Thu Jun 13 09:37:43 2013 +0200
+++ b/wxglade_hmi/wxglade_hmi.py	Thu Jun 13 09:42:59 2013 +0200
@@ -71,12 +71,16 @@
             define_hmi = hmipyfile.read().decode('utf-8')
             hmipyfile.close()
         
+        else:
+            define_hmi = ""
+        
         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']])
                                 for x in hmi_frames])
-        global_hmi = "global %s\n"%",".join(
-            [x["name"] for x in hmi_frames]) 
+        global_hmi = ("global %s\n"%",".join(
+                         [x["name"] for x in hmi_frames]) 
+                      if len(hmi_frames) > 0 else "")
         init_hmi = "\n".join(["""\
 def OnCloseFrame(evt):
     wx.MessageBox(_("Please stop PLC to close"))