69 wx.InitAllImageHandlers() |
70 wx.InitAllImageHandlers() |
70 |
71 |
71 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
72 bmp = wx.Image(Bpath("images","splash.png")).ConvertToBitmap() |
72 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
73 splash=wx.SplashScreen(bmp,wx.SPLASH_CENTRE_ON_SCREEN, 1000, None) |
73 wx.Yield() |
74 wx.Yield() |
|
75 |
|
76 # Import module for internationalization |
|
77 import gettext |
|
78 import __builtin__ |
|
79 |
|
80 # Get folder containing translation files |
|
81 localedir = os.path.join(CWD,"locale") |
|
82 # Get the default language |
|
83 langid = wx.LANGUAGE_DEFAULT |
|
84 # Define translation domain (name of translation files) |
|
85 domain = "Beremiz" |
|
86 |
|
87 # Define locale for wx |
|
88 loc = __builtin__.__dict__.get('loc', None) |
|
89 if loc is None: |
|
90 loc = wx.Locale(langid) |
|
91 __builtin__.__dict__['loc'] = loc |
|
92 # Define location for searching translation files |
|
93 loc.AddCatalogLookupPathPrefix(localedir) |
|
94 # Define locale domain |
|
95 loc.AddCatalog(domain) |
|
96 |
|
97 def unicode_translation(message): |
|
98 return wx.GetTranslation(message).encode("utf-8") |
|
99 |
|
100 if __name__ == '__main__': |
|
101 __builtin__.__dict__['_'] = wx.GetTranslation#unicode_translation |
74 |
102 |
75 import wx.lib.buttons, wx.lib.statbmp |
103 import wx.lib.buttons, wx.lib.statbmp |
76 import TextCtrlAutoComplete, cPickle |
104 import TextCtrlAutoComplete, cPickle |
77 import types, time, re, platform, time, traceback, commands |
105 import types, time, re, platform, time, traceback, commands |
78 from plugger import PluginsRoot, MATIEC_ERROR_MODEL |
106 from plugger import PluginsRoot, MATIEC_ERROR_MODEL |
253 |
281 |
254 class Beremiz(wx.Frame): |
282 class Beremiz(wx.Frame): |
255 |
283 |
256 def _init_coll_FileMenu_Items(self, parent): |
284 def _init_coll_FileMenu_Items(self, parent): |
257 parent.Append(help='', id=wx.ID_NEW, |
285 parent.Append(help='', id=wx.ID_NEW, |
258 kind=wx.ITEM_NORMAL, text=u'New\tCTRL+N') |
286 kind=wx.ITEM_NORMAL, text=_(u'New\tCTRL+N')) |
259 parent.Append(help='', id=wx.ID_OPEN, |
287 parent.Append(help='', id=wx.ID_OPEN, |
260 kind=wx.ITEM_NORMAL, text=u'Open\tCTRL+O') |
288 kind=wx.ITEM_NORMAL, text=_(u'Open\tCTRL+O')) |
261 parent.Append(help='', id=wx.ID_SAVE, |
289 parent.Append(help='', id=wx.ID_SAVE, |
262 kind=wx.ITEM_NORMAL, text=u'Save\tCTRL+S') |
290 kind=wx.ITEM_NORMAL, text=_(u'Save\tCTRL+S')) |
263 parent.Append(help='', id=wx.ID_CLOSE_ALL, |
291 parent.Append(help='', id=wx.ID_CLOSE_ALL, |
264 kind=wx.ITEM_NORMAL, text=u'Close Project') |
292 kind=wx.ITEM_NORMAL, text=_(u'Close Project')) |
265 parent.AppendSeparator() |
293 parent.AppendSeparator() |
266 parent.Append(help='', id=wx.ID_PROPERTIES, |
294 parent.Append(help='', id=wx.ID_PROPERTIES, |
267 kind=wx.ITEM_NORMAL, text=u'Properties') |
295 kind=wx.ITEM_NORMAL, text=_(u'Properties')) |
268 parent.AppendSeparator() |
296 parent.AppendSeparator() |
269 parent.Append(help='', id=wx.ID_EXIT, |
297 parent.Append(help='', id=wx.ID_EXIT, |
270 kind=wx.ITEM_NORMAL, text=u'Quit\tCTRL+Q') |
298 kind=wx.ITEM_NORMAL, text=_(u'Quit\tCTRL+Q')) |
271 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
299 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
272 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
300 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
273 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
301 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
274 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
302 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE_ALL) |
275 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
303 self.Bind(wx.EVT_MENU, self.OnPropertiesMenu, id=wx.ID_PROPERTIES) |
276 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
304 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
277 |
305 |
278 def _init_coll_EditMenu_Items(self, parent): |
306 def _init_coll_EditMenu_Items(self, parent): |
279 parent.Append(help='', id=wx.ID_EDIT, |
307 parent.Append(help='', id=wx.ID_EDIT, |
280 kind=wx.ITEM_NORMAL, text=u'Edit PLC\tCTRL+R') |
308 kind=wx.ITEM_NORMAL, text=_(u'Edit PLC\tCTRL+R')) |
281 parent.AppendSeparator() |
309 parent.AppendSeparator() |
282 parent.Append(help='', id=wx.ID_ADD, |
310 parent.Append(help='', id=wx.ID_ADD, |
283 kind=wx.ITEM_NORMAL, text=u'Add Plugin') |
311 kind=wx.ITEM_NORMAL, text=_(u'Add Plugin')) |
284 parent.Append(help='', id=wx.ID_DELETE, |
312 parent.Append(help='', id=wx.ID_DELETE, |
285 kind=wx.ITEM_NORMAL, text=u'Delete Plugin') |
313 kind=wx.ITEM_NORMAL, text=_(u'Delete Plugin')) |
286 self.Bind(wx.EVT_MENU, self.OnEditPLCMenu, id=wx.ID_EDIT) |
314 self.Bind(wx.EVT_MENU, self.OnEditPLCMenu, id=wx.ID_EDIT) |
287 self.Bind(wx.EVT_MENU, self.OnAddMenu, id=wx.ID_ADD) |
315 self.Bind(wx.EVT_MENU, self.OnAddMenu, id=wx.ID_ADD) |
288 self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) |
316 self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) |
289 |
317 |
290 def _init_coll_RunMenu_Items(self, parent): |
318 def _init_coll_RunMenu_Items(self, parent): |
291 parent.Append(help='', id=ID_BEREMIZRUNMENUBUILD, |
319 parent.Append(help='', id=ID_BEREMIZRUNMENUBUILD, |
292 kind=wx.ITEM_NORMAL, text=u'Build\tCTRL+R') |
320 kind=wx.ITEM_NORMAL, text=_(u'Build\tCTRL+R')) |
293 parent.AppendSeparator() |
321 parent.AppendSeparator() |
294 parent.Append(help='', id=ID_BEREMIZRUNMENUSIMULATE, |
322 parent.Append(help='', id=ID_BEREMIZRUNMENUSIMULATE, |
295 kind=wx.ITEM_NORMAL, text=u'Simulate') |
323 kind=wx.ITEM_NORMAL, text=_(u'Simulate')) |
296 parent.Append(help='', id=ID_BEREMIZRUNMENURUN, |
324 parent.Append(help='', id=ID_BEREMIZRUNMENURUN, |
297 kind=wx.ITEM_NORMAL, text=u'Run') |
325 kind=wx.ITEM_NORMAL, text=_(u'Run')) |
298 parent.AppendSeparator() |
326 parent.AppendSeparator() |
299 parent.Append(help='', id=ID_BEREMIZRUNMENUSAVELOG, |
327 parent.Append(help='', id=ID_BEREMIZRUNMENUSAVELOG, |
300 kind=wx.ITEM_NORMAL, text=u'Save Log') |
328 kind=wx.ITEM_NORMAL, text=_(u'Save Log')) |
301 self.Bind(wx.EVT_MENU, self.OnBuildMenu, |
329 self.Bind(wx.EVT_MENU, self.OnBuildMenu, |
302 id=ID_BEREMIZRUNMENUBUILD) |
330 id=ID_BEREMIZRUNMENUBUILD) |
303 self.Bind(wx.EVT_MENU, self.OnSimulateMenu, |
331 self.Bind(wx.EVT_MENU, self.OnSimulateMenu, |
304 id=ID_BEREMIZRUNMENUSIMULATE) |
332 id=ID_BEREMIZRUNMENUSIMULATE) |
305 self.Bind(wx.EVT_MENU, self.OnRunMenu, |
333 self.Bind(wx.EVT_MENU, self.OnRunMenu, |
307 self.Bind(wx.EVT_MENU, self.OnSaveLogMenu, |
335 self.Bind(wx.EVT_MENU, self.OnSaveLogMenu, |
308 id=ID_BEREMIZRUNMENUSAVELOG) |
336 id=ID_BEREMIZRUNMENUSAVELOG) |
309 |
337 |
310 def _init_coll_HelpMenu_Items(self, parent): |
338 def _init_coll_HelpMenu_Items(self, parent): |
311 parent.Append(help='', id=wx.ID_HELP, |
339 parent.Append(help='', id=wx.ID_HELP, |
312 kind=wx.ITEM_NORMAL, text=u'Beremiz\tF1') |
340 kind=wx.ITEM_NORMAL, text=_(u'Beremiz\tF1')) |
313 parent.Append(help='', id=wx.ID_ABOUT, |
341 parent.Append(help='', id=wx.ID_ABOUT, |
314 kind=wx.ITEM_NORMAL, text=u'About') |
342 kind=wx.ITEM_NORMAL, text=_(u'About')) |
315 self.Bind(wx.EVT_MENU, self.OnBeremizMenu, id=wx.ID_HELP) |
343 self.Bind(wx.EVT_MENU, self.OnBeremizMenu, id=wx.ID_HELP) |
316 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
344 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
317 |
345 |
318 def _init_coll_MenuBar_Menus(self, parent): |
346 def _init_coll_MenuBar_Menus(self, parent): |
319 parent.Append(menu=self.FileMenu, title=u'File') |
347 parent.Append(menu=self.FileMenu, title=_(u'File')) |
320 #parent.Append(menu=self.EditMenu, title=u'Edit') |
348 #parent.Append(menu=self.EditMenu, title=u'Edit') |
321 #parent.Append(menu=self.RunMenu, title=u'Run') |
349 #parent.Append(menu=self.RunMenu, title=u'Run') |
322 parent.Append(menu=self.HelpMenu, title=u'Help') |
350 parent.Append(menu=self.HelpMenu, title=_(u'Help')) |
323 |
351 |
324 def _init_utils(self): |
352 def _init_utils(self): |
325 self.MenuBar = wx.MenuBar() |
353 self.MenuBar = wx.MenuBar() |
326 self.FileMenu = wx.Menu(title=u'') |
354 self.FileMenu = wx.Menu(title=u'') |
327 #self.EditMenu = wx.Menu(title=u'') |
355 #self.EditMenu = wx.Menu(title=u'') |
579 |
607 |
580 addbutton_id = wx.NewId() |
608 addbutton_id = wx.NewId() |
581 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
609 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
582 name='AddPluginButton', parent=plcwindow, pos=wx.Point(0, 0), |
610 name='AddPluginButton', parent=plcwindow, pos=wx.Point(0, 0), |
583 size=wx.Size(16, 16), style=wx.NO_BORDER) |
611 size=wx.Size(16, 16), style=wx.NO_BORDER) |
584 addbutton.SetToolTipString("Add a sub plugin") |
612 addbutton.SetToolTipString(_("Add a sub plugin")) |
585 addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(self.PluginRoot), id=addbutton_id) |
613 addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(self.PluginRoot), id=addbutton_id) |
586 plcwindowsizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
614 plcwindowsizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
587 |
615 |
588 plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
616 plcwindowmainsizer = wx.BoxSizer(wx.VERTICAL) |
589 plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
617 plcwindowsizer.AddSizer(plcwindowmainsizer, 0, border=5, flag=wx.ALL) |
782 leftsizer.AddSizer(rolesizer, 0, border=0, flag=wx.GROW|wx.RIGHT) |
810 leftsizer.AddSizer(rolesizer, 0, border=0, flag=wx.GROW|wx.RIGHT) |
783 |
811 |
784 enablebutton_id = wx.NewId() |
812 enablebutton_id = wx.NewId() |
785 enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')), |
813 enablebutton = wx.lib.buttons.GenBitmapToggleButton(id=enablebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Disabled.png')), |
786 name='EnableButton', parent=leftwindow, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER) |
814 name='EnableButton', parent=leftwindow, size=wx.Size(16, 16), pos=wx.Point(0, 0), style=0)#wx.NO_BORDER) |
787 enablebutton.SetToolTipString("Enable/Disable this plugin") |
815 enablebutton.SetToolTipString(_("Enable/Disable this plugin")) |
788 make_genbitmaptogglebutton_flat(enablebutton) |
816 make_genbitmaptogglebutton_flat(enablebutton) |
789 enablebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Enabled.png'))) |
817 enablebutton.SetBitmapSelected(wx.Bitmap(Bpath( 'images', 'Enabled.png'))) |
790 enablebutton.SetToggle(plugin.MandatoryParams[1].getEnabled()) |
818 enablebutton.SetToggle(plugin.MandatoryParams[1].getEnabled()) |
791 def toggleenablebutton(event): |
819 def toggleenablebutton(event): |
792 res = self.SetPluginParamsAttribute(plugin, "BaseParams.Enabled", enablebutton.GetToggle()) |
820 res = self.SetPluginParamsAttribute(plugin, "BaseParams.Enabled", enablebutton.GetToggle()) |
832 |
860 |
833 deletebutton_id = wx.NewId() |
861 deletebutton_id = wx.NewId() |
834 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Delete.png')), |
862 deletebutton = wx.lib.buttons.GenBitmapButton(id=deletebutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Delete.png')), |
835 name='DeletePluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
863 name='DeletePluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
836 size=wx.Size(16, 16), style=wx.NO_BORDER) |
864 size=wx.Size(16, 16), style=wx.NO_BORDER) |
837 deletebutton.SetToolTipString("Delete this plugin") |
865 deletebutton.SetToolTipString(_("Delete this plugin")) |
838 deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id) |
866 deletebutton.Bind(wx.EVT_BUTTON, self.GetDeleteButtonFunction(plugin), id=deletebutton_id) |
839 adddeletesizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
867 adddeletesizer.AddWindow(deletebutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
840 |
868 |
841 if len(plugin.PlugChildsTypes) > 0: |
869 if len(plugin.PlugChildsTypes) > 0: |
842 addbutton_id = wx.NewId() |
870 addbutton_id = wx.NewId() |
843 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
871 addbutton = wx.lib.buttons.GenBitmapButton(id=addbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'Add.png')), |
844 name='AddPluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
872 name='AddPluginButton', parent=leftwindow, pos=wx.Point(0, 0), |
845 size=wx.Size(16, 16), style=wx.NO_BORDER) |
873 size=wx.Size(16, 16), style=wx.NO_BORDER) |
846 addbutton.SetToolTipString("Add a sub plugin") |
874 addbutton.SetToolTipString(_("Add a sub plugin")) |
847 addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(plugin), id=addbutton_id) |
875 addbutton.Bind(wx.EVT_BUTTON, self.Gen_AddPluginMenu(plugin), id=addbutton_id) |
848 adddeletesizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
876 adddeletesizer.AddWindow(addbutton, 0, border=5, flag=wx.RIGHT|wx.ALIGN_CENTER) |
849 |
877 |
850 expandbutton_id = wx.NewId() |
878 expandbutton_id = wx.NewId() |
851 expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
879 expandbutton = wx.lib.buttons.GenBitmapToggleButton(id=expandbutton_id, bitmap=wx.Bitmap(Bpath( 'images', 'plus.png')), |
1128 sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
1157 sizer.AddSizer(boxsizer, 0, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM) |
1129 staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"], |
1158 staticbitmap = GenStaticBitmap(ID=-1, bitmapname="%s.png"%element_infos["name"], |
1130 name="%s_bitmap"%element_infos["name"], parent=parent, |
1159 name="%s_bitmap"%element_infos["name"], parent=parent, |
1131 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
1160 pos=wx.Point(0, 0), size=wx.Size(24, 24), style=0) |
1132 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
1161 boxsizer.AddWindow(staticbitmap, 0, border=5, flag=wx.RIGHT) |
1133 statictext = wx.StaticText(id=-1, label="%s:"%element_infos["name"], |
1162 label = element_infos["name"] |
|
1163 statictext = wx.StaticText(id=-1, label="%s:"%_(label), |
1134 name="%s_label"%element_infos["name"], parent=parent, |
1164 name="%s_label"%element_infos["name"], parent=parent, |
1135 pos=wx.Point(0, 0), size=wx.Size(100, 17), style=0) |
1165 pos=wx.Point(0, 0), size=wx.DefaultSize, style=0) |
1136 boxsizer.AddWindow(statictext, 0, border=4, flag=wx.TOP) |
1166 boxsizer.AddWindow(statictext, 0, border=5, flag=wx.ALIGN_CENTER_VERTICAL|wx.RIGHT) |
1137 id = wx.NewId() |
1167 id = wx.NewId() |
1138 if isinstance(element_infos["type"], types.ListType): |
1168 if isinstance(element_infos["type"], types.ListType): |
1139 combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
1169 combobox = wx.ComboBox(id=id, name=element_infos["name"], parent=parent, |
1140 pos=wx.Point(0, 0), size=wx.Size(150, 28), style=wx.CB_READONLY) |
1170 pos=wx.Point(0, 0), size=wx.Size(150, 28), style=wx.CB_READONLY) |
1141 boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
1171 boxsizer.AddWindow(combobox, 0, border=0, flag=0) |
1142 if element_infos["use"] == "optional": |
1172 if element_infos["use"] == "optional": |
1143 combobox.Append("") |
1173 combobox.Append("") |
1144 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1174 if len(element_infos["type"]) > 0 and isinstance(element_infos["type"][0], types.TupleType): |
1145 for choice, xsdclass in element_infos["type"]: |
1175 for choice, xsdclass in element_infos["type"]: |
1146 combobox.Append(choice) |
1176 combobox.Append(choice) |
1147 staticbox = wx.StaticBox(id=-1, label="%(name)s - %(value)s"%element_infos, |
1177 name = element_infos["name"] |
|
1178 value = element_infos["value"] |
|
1179 staticbox = wx.StaticBox(id=-1, label="%s - %s"%(_(name), _(value)), |
1148 name='%s_staticbox'%element_infos["name"], parent=parent, |
1180 name='%s_staticbox'%element_infos["name"], parent=parent, |
1149 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
1181 pos=wx.Point(0, 0), size=wx.Size(10, 0), style=0) |
1150 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1182 staticboxsizer = wx.StaticBoxSizer(staticbox, wx.VERTICAL) |
1151 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
1183 sizer.AddSizer(staticboxsizer, 0, border=5, flag=wx.GROW|wx.BOTTOM) |
1152 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
1184 self.RefreshSizerElement(parent, staticboxsizer, plugin, element_infos["children"], element_path) |
1247 result = self.PluginRoot.LoadProject(projectpath) |
1279 result = self.PluginRoot.LoadProject(projectpath) |
1248 if not result: |
1280 if not result: |
1249 self.RefreshAll() |
1281 self.RefreshAll() |
1250 self.RefreshMainMenu() |
1282 self.RefreshMainMenu() |
1251 else: |
1283 else: |
1252 message = wx.MessageDialog(self, result, "Error", wx.OK|wx.ICON_ERROR) |
1284 message = wx.MessageDialog(self, result, _("Error"), wx.OK|wx.ICON_ERROR) |
1253 message.ShowModal() |
1285 message.ShowModal() |
1254 message.Destroy() |
1286 message.Destroy() |
1255 else: |
1287 else: |
1256 message = wx.MessageDialog(self, "\"%s\" folder is not a valid Beremiz project\n"%projectpath, "Error", wx.OK|wx.ICON_ERROR) |
1288 message = wx.MessageDialog(self, _("\"%s\" folder is not a valid Beremiz project\n")%projectpath, _("Error"), wx.OK|wx.ICON_ERROR) |
1257 message.ShowModal() |
1289 message.ShowModal() |
1258 message.Destroy() |
1290 message.Destroy() |
1259 dialog.Destroy() |
1291 dialog.Destroy() |
1260 event.Skip() |
1292 event.Skip() |
1261 |
1293 |
1262 def OnCloseProjectMenu(self, event): |
1294 def OnCloseProjectMenu(self, event): |
1263 if self.PluginRoot is not None: |
1295 if self.PluginRoot is not None: |
1264 if self.PluginRoot.ProjectTestModified(): |
1296 if self.PluginRoot.ProjectTestModified(): |
1265 dialog = wx.MessageDialog(self, |
1297 dialog = wx.MessageDialog(self, |
1266 "Save changes ?", |
1298 _("Save changes ?"), |
1267 "Close Application", |
1299 _("Close Application"), |
1268 wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
1300 wx.YES_NO|wx.CANCEL|wx.ICON_QUESTION) |
1269 answer = dialog.ShowModal() |
1301 answer = dialog.ShowModal() |
1270 dialog.Destroy() |
1302 dialog.Destroy() |
1271 if answer == wx.ID_YES: |
1303 if answer == wx.ID_YES: |
1272 self.PluginRoot.SaveProject() |
1304 self.PluginRoot.SaveProject() |
1353 wx.CallAfter(self.DeletePlugin, plugin) |
1385 wx.CallAfter(self.DeletePlugin, plugin) |
1354 event.Skip() |
1386 event.Skip() |
1355 return DeleteButtonFunction |
1387 return DeleteButtonFunction |
1356 |
1388 |
1357 def AddPlugin(self, PluginType, plugin): |
1389 def AddPlugin(self, PluginType, plugin): |
1358 dialog = wx.TextEntryDialog(self, "Please enter a name for plugin:", "Add Plugin", "", wx.OK|wx.CANCEL) |
1390 dialog = wx.TextEntryDialog(self, _("Please enter a name for plugin:"), _("Add Plugin"), "", wx.OK|wx.CANCEL) |
1359 if dialog.ShowModal() == wx.ID_OK: |
1391 if dialog.ShowModal() == wx.ID_OK: |
1360 PluginName = dialog.GetValue() |
1392 PluginName = dialog.GetValue() |
1361 plugin.PlugAddChild(PluginName, PluginType) |
1393 plugin.PlugAddChild(PluginName, PluginType) |
1362 self.RefreshPluginTree() |
1394 self.RefreshPluginTree() |
1363 dialog.Destroy() |
1395 dialog.Destroy() |
1364 |
1396 |
1365 def DeletePlugin(self, plugin): |
1397 def DeletePlugin(self, plugin): |
1366 dialog = wx.MessageDialog(self, "Really delete plugin ?", "Remove plugin", wx.YES_NO|wx.NO_DEFAULT) |
1398 dialog = wx.MessageDialog(self, _("Really delete plugin ?"), _("Remove plugin"), wx.YES_NO|wx.NO_DEFAULT) |
1367 if dialog.ShowModal() == wx.ID_YES: |
1399 if dialog.ShowModal() == wx.ID_YES: |
1368 self.PluginInfos.pop(plugin) |
1400 self.PluginInfos.pop(plugin) |
1369 plugin.PlugRemove() |
1401 plugin.PlugRemove() |
1370 del plugin |
1402 del plugin |
1371 self.RefreshPluginTree() |
1403 self.RefreshPluginTree() |
1378 Max_Traceback_List_Size = 20 |
1410 Max_Traceback_List_Size = 20 |
1379 |
1411 |
1380 def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path): |
1412 def Display_Exception_Dialog(e_type, e_value, e_tb, bug_report_path): |
1381 trcbck_lst = [] |
1413 trcbck_lst = [] |
1382 for i,line in enumerate(traceback.extract_tb(e_tb)): |
1414 for i,line in enumerate(traceback.extract_tb(e_tb)): |
1383 trcbck = " " + str(i+1) + ". " |
1415 trcbck = " " + str(i+1) + _(". ") |
1384 if line[0].find(os.getcwd()) == -1: |
1416 if line[0].find(os.getcwd()) == -1: |
1385 trcbck += "file : " + str(line[0]) + ", " |
1417 trcbck += _("file : ") + str(line[0]) + _(", ") |
1386 else: |
1418 else: |
1387 trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
1419 trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(", ") |
1388 trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
1420 trcbck += _("line : ") + str(line[1]) + _(", ") + _("function : ") + str(line[2]) |
1389 trcbck_lst.append(trcbck) |
1421 trcbck_lst.append(trcbck) |
1390 |
1422 |
1391 # Allow clicking.... |
1423 # Allow clicking.... |
1392 cap = wx.Window_GetCapture() |
1424 cap = wx.Window_GetCapture() |
1393 if cap: |
1425 if cap: |
1394 cap.ReleaseMouse() |
1426 cap.ReleaseMouse() |
1395 |
1427 |
1396 dlg = wx.SingleChoiceDialog(None, |
1428 dlg = wx.SingleChoiceDialog(None, |
1397 """ |
1429 _(""" |
1398 An unhandled exception (bug) occured. Bug report saved at : |
1430 An unhandled exception (bug) occured. Bug report saved at : |
1399 (%s) |
1431 (%s) |
1400 |
1432 |
1401 Please contact LOLITech at: |
1433 Please contact LOLITech at: |
1402 +33 (0)3 29 57 60 42 |
1434 +33 (0)3 29 57 60 42 |