61 else: |
61 else: |
62 projectOpen = None |
62 projectOpen = None |
63 buildpath = None |
63 buildpath = None |
64 |
64 |
65 app = wx.PySimpleApp() |
65 app = wx.PySimpleApp() |
|
66 app.SetAppName('beremiz') |
|
67 config = wx.ConfigBase.Get() |
66 wx.InitAllImageHandlers() |
68 wx.InitAllImageHandlers() |
67 |
69 |
68 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
70 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
69 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
71 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
70 wx.Yield() |
72 wx.Yield() |
1175 textctrl.ChangeValue(str(element_infos["value"])) |
1177 textctrl.ChangeValue(str(element_infos["value"])) |
1176 textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) |
1178 textctrl.Bind(wx.EVT_TEXT, self.GetTextCtrlCallBackFunction(textctrl, plugin, element_path)) |
1177 first = False |
1179 first = False |
1178 |
1180 |
1179 def OnNewProjectMenu(self, event): |
1181 def OnNewProjectMenu(self, event): |
1180 defaultpath = config.Read("workspacedir") |
1182 if not config.HasEntry("lastopenedfolder"): |
1181 if self.PluginRoot is not None: |
1183 defaultpath = os.path.expanduser("~") |
1182 defaultpath = self.PluginRoot.GetProjectPath() |
1184 else: |
|
1185 defaultpath = config.Read("lastopenedfolder") |
1183 |
1186 |
1184 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
1187 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
1185 if dialog.ShowModal() == wx.ID_OK: |
1188 if dialog.ShowModal() == wx.ID_OK: |
|
1189 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
|
1190 config.Flush() |
1186 projectpath = dialog.GetPath() |
1191 projectpath = dialog.GetPath() |
1187 dialog.Destroy() |
1192 dialog.Destroy() |
1188 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1193 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1189 res = self.PluginRoot.NewProject(projectpath) |
1194 res = self.PluginRoot.NewProject(projectpath) |
1190 if not res : |
1195 if not res : |
1196 message.ShowModal() |
1201 message.ShowModal() |
1197 message.Destroy() |
1202 message.Destroy() |
1198 event.Skip() |
1203 event.Skip() |
1199 |
1204 |
1200 def OnOpenProjectMenu(self, event): |
1205 def OnOpenProjectMenu(self, event): |
1201 defaultpath = config.Read("workspacedir") |
1206 if not config.HasEntry("lastopenedfolder"): |
1202 if self.PluginRoot is not None: |
1207 defaultpath = os.path.expanduser("~") |
1203 defaultpath = self.PluginRoot.GetProjectPath() |
1208 else: |
|
1209 defaultpath = config.Read("lastopenedfolder") |
1204 |
1210 |
1205 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
1211 dialog = wx.DirDialog(self , "Choose a project", defaultpath, wx.DD_NEW_DIR_BUTTON) |
1206 if dialog.ShowModal() == wx.ID_OK: |
1212 if dialog.ShowModal() == wx.ID_OK: |
1207 projectpath = dialog.GetPath() |
1213 projectpath = dialog.GetPath() |
1208 if os.path.isdir(projectpath): |
1214 if os.path.isdir(projectpath): |
|
1215 config.Write("lastopenedfolder", os.path.dirname(projectpath)) |
|
1216 config.Flush() |
1209 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1217 self.PluginRoot = PluginsRoot(self, self.Log, self.runtime_port) |
1210 result = self.PluginRoot.LoadProject(projectpath) |
1218 result = self.PluginRoot.LoadProject(projectpath) |
1211 if not result: |
1219 if not result: |
1212 self.RefreshPLCParams() |
1220 self.RefreshPLCParams() |
1213 self.RefreshPluginTree() |
1221 self.RefreshPluginTree() |
1445 AddExceptHook(os.getcwd(),__version__) |
1453 AddExceptHook(os.getcwd(),__version__) |
1446 |
1454 |
1447 frame = Beremiz(None, projectOpen, buildpath) |
1455 frame = Beremiz(None, projectOpen, buildpath) |
1448 frame.Show() |
1456 frame.Show() |
1449 splash.Close() |
1457 splash.Close() |
1450 config = wx.ConfigBase.Get() |
|
1451 if not config.HasEntry("workspacedir"): |
|
1452 defaultpath = os.path.expanduser("~") |
|
1453 dialog = wx.DirDialog(frame, "Select a Workspace", defaultpath, wx.DD_NEW_DIR_BUTTON) |
|
1454 if dialog.ShowModal() == wx.ID_OK: |
|
1455 defaultpath = dialog.GetPath() |
|
1456 dialog.Destroy() |
|
1457 config.Write("workspacedir", defaultpath) |
|
1458 config.Flush() |
|
1459 app.MainLoop() |
1458 app.MainLoop() |