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 |