wxglade_hmi/wxglade_hmi.py
changeset 1878 fb73a6b6622d
parent 1832 0f1081928d65
child 1881 091005ec69c4
equal deleted inserted replaced
1877:da5f1fa46f2b 1878:fb73a6b6622d
   122             define_hmi = ""
   122             define_hmi = ""
   123 
   123 
   124         declare_hmi = "\n".join(["%(name)s = None\n" % x +
   124         declare_hmi = "\n".join(["%(name)s = None\n" % x +
   125                                  "\n".join(["%(class)s.%(h)s = %(h)s" %
   125                                  "\n".join(["%(class)s.%(h)s = %(h)s" %
   126                                             dict(x, h=h) for h in x['handlers']])
   126                                             dict(x, h=h) for h in x['handlers']])
   127                                 for x in hmi_frames])
   127                                  for x in hmi_frames])
   128         global_hmi = ("global %s\n" % ",".join(
   128         global_hmi = ("global %s\n" % ",".join(
   129                          [x["name"] for x in hmi_frames])
   129             [x["name"] for x in hmi_frames]) if len(hmi_frames) > 0 else "")
   130                       if len(hmi_frames) > 0 else "")
       
   131         init_hmi = "\n".join(["""\
   130         init_hmi = "\n".join(["""\
   132 def OnCloseFrame(evt):
   131 def OnCloseFrame(evt):
   133     wx.MessageBox(_("Please stop PLC to close"))
   132     wx.MessageBox(_("Please stop PLC to close"))
   134 
   133 
   135 %(name)s = %(class)s(None)
   134 %(name)s = %(class)s(None)
   136 %(name)s.Bind(wx.EVT_CLOSE, OnCloseFrame)
   135 %(name)s.Bind(wx.EVT_CLOSE, OnCloseFrame)
   137 %(name)s.Show()
   136 %(name)s.Show()
   138 """ % x for x in hmi_frames])
   137 """ % x for x in hmi_frames])
   139         cleanup_hmi = "\n".join(
   138         cleanup_hmi = "\n".join(
   140             ["if %(name)s is not None: %(name)s.Destroy()" % x
   139             ["if %(name)s is not None: %(name)s.Destroy()" % x
   141                 for x in hmi_frames])
   140              for x in hmi_frames])
   142 
   141 
   143         self.PreSectionsTexts = {
   142         self.PreSectionsTexts = {
   144             "globals": define_hmi,
   143             "globals": define_hmi,
   145             "start":   global_hmi,
   144             "start":   global_hmi,
   146             "stop":    global_hmi + cleanup_hmi
   145             "stop":    global_hmi + cleanup_hmi