71 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
71 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
72 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
72 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
73 wx.Yield() |
73 wx.Yield() |
74 |
74 |
75 import wx.lib.buttons, wx.lib.statbmp |
75 import wx.lib.buttons, wx.lib.statbmp |
|
76 import TextCtrlAutoComplete, cPickle |
76 import types, time, re, platform, time, traceback, commands |
77 import types, time, re, platform, time, traceback, commands |
77 from plugger import PluginsRoot |
78 from plugger import PluginsRoot |
78 from wxPopen import ProcessLogger |
79 from wxPopen import ProcessLogger |
79 |
80 |
80 base_folder = os.path.split(sys.path[0])[0] |
81 base_folder = os.path.split(sys.path[0])[0] |
436 self.PluginInfos = {} |
437 self.PluginInfos = {} |
437 |
438 |
438 if projectOpen: |
439 if projectOpen: |
439 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
440 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
440 self.PluginRoot.LoadProject(projectOpen, buildpath) |
441 self.PluginRoot.LoadProject(projectOpen, buildpath) |
441 self.RefreshPLCParams() |
442 self.RefreshAll() |
442 self.RefreshPluginTree() |
|
443 else: |
443 else: |
444 self.PluginRoot = None |
444 self.PluginRoot = None |
445 |
445 |
446 self.RefreshMainMenu() |
446 self.RefreshMainMenu() |
447 |
447 |
1170 spinctrl.SetRange(scmin, scmax) |
1170 spinctrl.SetRange(scmin, scmax) |
1171 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1171 boxsizer.AddWindow(spinctrl, 0, border=0, flag=0) |
1172 spinctrl.SetValue(element_infos["value"]) |
1172 spinctrl.SetValue(element_infos["value"]) |
1173 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1173 spinctrl.Bind(wx.EVT_SPINCTRL, self.GetTextCtrlCallBackFunction(spinctrl, plugin, element_path), id=id) |
1174 else: |
1174 else: |
1175 textctrl = wx.TextCtrl(id=id, name=element_infos["name"], parent=parent, |
1175 choices = cPickle.loads(str(config.Read(element_path, cPickle.dumps([""])))) |
1176 pos=wx.Point(0, 0), size=wx.Size(150, 25), style=0)#wx.TE_PROCESS_ENTER) |
1176 textctrl = TextCtrlAutoComplete.TextCtrlAutoComplete(id=id, |
|
1177 name=element_infos["name"], |
|
1178 parent=parent, |
|
1179 choices=choices, |
|
1180 selectCallback = None, |
|
1181 element_path=element_path, |
|
1182 pos=wx.Point(0, 0), |
|
1183 size=wx.Size(150, 25), |
|
1184 style=0) |
|
1185 |
1177 boxsizer.AddWindow(textctrl, 0, border=0, flag=0) |
1186 boxsizer.AddWindow(textctrl, 0, border=0, flag=0) |
1178 textctrl.ChangeValue(str(element_infos["value"])) |
1187 textctrl.ChangeValue(str(element_infos["value"])) |
1179 textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) |
1188 textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) |
1180 first = False |
1189 first = False |
1181 |
1190 |
1192 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
1201 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
1193 config.Flush() |
1202 config.Flush() |
1194 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1203 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1195 res = self.PluginRoot.NewProject(projectpath) |
1204 res = self.PluginRoot.NewProject(projectpath) |
1196 if not res : |
1205 if not res : |
1197 self.RefreshPLCParams() |
1206 self.RefreshAll() |
1198 self.RefreshPluginTree() |
|
1199 self.RefreshMainMenu() |
1207 self.RefreshMainMenu() |
1200 else: |
1208 else: |
1201 message = wx.MessageDialog(self, res, "ERROR", wx.OK|wx.ICON_ERROR) |
1209 message = wx.MessageDialog(self, res, "ERROR", wx.OK|wx.ICON_ERROR) |
1202 message.ShowModal() |
1210 message.ShowModal() |
1203 message.Destroy() |
1211 message.Destroy() |
1216 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
1224 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
1217 config.Flush() |
1225 config.Flush() |
1218 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1226 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1219 result = self.PluginRoot.LoadProject(projectpath) |
1227 result = self.PluginRoot.LoadProject(projectpath) |
1220 if not result: |
1228 if not result: |
1221 self.RefreshPLCParams() |
1229 self.RefreshAll() |
1222 self.RefreshPluginTree() |
|
1223 self.RefreshMainMenu() |
1230 self.RefreshMainMenu() |
1224 else: |
1231 else: |
1225 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
1232 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
1226 message.ShowModal() |
1233 message.ShowModal() |
1227 message.Destroy() |
1234 message.Destroy() |
1246 elif answer == wx.ID_CANCEL: |
1253 elif answer == wx.ID_CANCEL: |
1247 return |
1254 return |
1248 self.PluginInfos = {} |
1255 self.PluginInfos = {} |
1249 self.PluginRoot = None |
1256 self.PluginRoot = None |
1250 self.Log.flush() |
1257 self.Log.flush() |
1251 self.RefreshPLCParams() |
1258 self.RefreshAll() |
1252 self.RefreshPluginTree() |
|
1253 self.RefreshMainMenu() |
1259 self.RefreshMainMenu() |
1254 event.Skip() |
1260 event.Skip() |
1255 |
1261 |
1256 def OnSaveProjectMenu(self, event): |
1262 def OnSaveProjectMenu(self, event): |
1257 if self.PluginRoot is not None: |
1263 if self.PluginRoot is not None: |