25 import wx.grid |
25 import wx.grid |
26 |
26 |
27 from types import * |
27 from types import * |
28 import os, re, platform, sys, time, traceback, getopt |
28 import os, re, platform, sys, time, traceback, getopt |
29 |
29 |
30 __version__ = "$Revision$" |
30 __version__ = "$Revision: 1.27 $" |
|
31 |
|
32 if __name__ == '__main__': |
|
33 def usage(): |
|
34 print _("\nUsage of networkedit.py :") |
|
35 print "\n %s [Projectpath]\n"%sys.argv[0] |
|
36 |
|
37 try: |
|
38 opts, args = getopt.getopt(sys.argv[1:], "h", ["help"]) |
|
39 except getopt.GetoptError: |
|
40 # print help information and exit: |
|
41 usage() |
|
42 sys.exit(2) |
|
43 |
|
44 for o, a in opts: |
|
45 if o in ("-h", "--help"): |
|
46 usage() |
|
47 sys.exit() |
|
48 |
|
49 if len(args) == 0: |
|
50 projectOpen = None |
|
51 elif len(args) == 1: |
|
52 projectOpen = args[0] |
|
53 else: |
|
54 usage() |
|
55 sys.exit(2) |
|
56 |
|
57 app = wx.PySimpleApp() |
|
58 |
|
59 ScriptDirectory = os.path.split(os.path.realpath(__file__))[0] |
|
60 |
|
61 # Import module for internationalization |
|
62 import gettext |
|
63 import __builtin__ |
|
64 |
|
65 # Get folder containing translation files |
|
66 localedir = os.path.join(ScriptDirectory,"locale") |
|
67 # Get the default language |
|
68 langid = wx.LANGUAGE_DEFAULT |
|
69 # Define translation domain (name of translation files) |
|
70 domain = "objdictgen" |
|
71 |
|
72 # Define locale for wx |
|
73 loc = __builtin__.__dict__.get('loc', None) |
|
74 if loc is None: |
|
75 loc = wx.Locale(langid) |
|
76 __builtin__.__dict__['loc'] = loc |
|
77 # Define location for searching translation files |
|
78 loc.AddCatalogLookupPathPrefix(localedir) |
|
79 # Define locale domain |
|
80 loc.AddCatalog(domain) |
|
81 |
|
82 if __name__ == '__main__': |
|
83 __builtin__.__dict__['_'] = wx.GetTranslation |
31 |
84 |
32 from nodelist import * |
85 from nodelist import * |
33 from nodemanager import * |
86 from nodemanager import * |
34 from subindextable import * |
87 from subindextable import * |
35 from commondialogs import * |
88 from commondialogs import * |
36 from doc_index.DS301_index import * |
89 from doc_index.DS301_index import * |
37 |
|
38 ScriptDirectory = os.path.split(os.path.realpath(__file__))[0] |
|
39 |
90 |
40 try: |
91 try: |
41 import wx.html |
92 import wx.html |
42 |
93 |
43 EVT_HTML_URL_CLICK = wx.NewId() |
94 EVT_HTML_URL_CLICK = wx.NewId() |
126 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
177 ] = [wx.NewId() for _init_coll_AddMenu_Items in range(6)] |
127 |
178 |
128 class networkedit(wx.Frame): |
179 class networkedit(wx.Frame): |
129 def _init_coll_MenuBar_Menus(self, parent): |
180 def _init_coll_MenuBar_Menus(self, parent): |
130 if self.ModeSolo: |
181 if self.ModeSolo: |
131 parent.Append(menu=self.FileMenu, title='File') |
182 parent.Append(menu=self.FileMenu, title=_('File')) |
132 parent.Append(menu=self.NetworkMenu, title='Network') |
183 parent.Append(menu=self.NetworkMenu, title=_('Network')) |
133 parent.Append(menu=self.EditMenu, title='Edit') |
184 parent.Append(menu=self.EditMenu, title=_('Edit')) |
134 parent.Append(menu=self.AddMenu, title='Add') |
185 parent.Append(menu=self.AddMenu, title=_('Add')) |
135 parent.Append(menu=self.HelpMenu, title='Help') |
186 parent.Append(menu=self.HelpMenu, title=_('Help')) |
136 |
187 |
137 def _init_coll_FileMenu_Items(self, parent): |
188 def _init_coll_FileMenu_Items(self, parent): |
138 parent.Append(help='', id=wx.ID_NEW, |
189 parent.Append(help='', id=wx.ID_NEW, |
139 kind=wx.ITEM_NORMAL, text='New\tCTRL+N') |
190 kind=wx.ITEM_NORMAL, text=_('New\tCTRL+N')) |
140 parent.Append(help='', id=wx.ID_OPEN, |
191 parent.Append(help='', id=wx.ID_OPEN, |
141 kind=wx.ITEM_NORMAL, text='Open\tCTRL+O') |
192 kind=wx.ITEM_NORMAL, text=_('Open\tCTRL+O')) |
142 parent.Append(help='', id=wx.ID_CLOSE, |
193 parent.Append(help='', id=wx.ID_CLOSE, |
143 kind=wx.ITEM_NORMAL, text='Close\tCTRL+W') |
194 kind=wx.ITEM_NORMAL, text=_('Close\tCTRL+W')) |
144 parent.AppendSeparator() |
195 parent.AppendSeparator() |
145 parent.Append(help='', id=wx.ID_SAVE, |
196 parent.Append(help='', id=wx.ID_SAVE, |
146 kind=wx.ITEM_NORMAL, text='Save\tCTRL+S') |
197 kind=wx.ITEM_NORMAL, text=_('Save\tCTRL+S')) |
147 parent.AppendSeparator() |
198 parent.AppendSeparator() |
148 parent.Append(help='', id=wx.ID_EXIT, |
199 parent.Append(help='', id=wx.ID_EXIT, |
149 kind=wx.ITEM_NORMAL, text='Exit') |
200 kind=wx.ITEM_NORMAL, text=_('Exit')) |
150 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
201 self.Bind(wx.EVT_MENU, self.OnNewProjectMenu, id=wx.ID_NEW) |
151 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
202 self.Bind(wx.EVT_MENU, self.OnOpenProjectMenu, id=wx.ID_OPEN) |
152 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE) |
203 self.Bind(wx.EVT_MENU, self.OnCloseProjectMenu, id=wx.ID_CLOSE) |
153 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
204 self.Bind(wx.EVT_MENU, self.OnSaveProjectMenu, id=wx.ID_SAVE) |
154 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
205 self.Bind(wx.EVT_MENU, self.OnQuitMenu, id=wx.ID_EXIT) |
155 |
206 |
156 def _init_coll_NetworkMenu_Items(self, parent): |
207 def _init_coll_NetworkMenu_Items(self, parent): |
157 parent.Append(help='', id=wx.ID_ADD, |
208 parent.Append(help='', id=wx.ID_ADD, |
158 kind=wx.ITEM_NORMAL, text='Add Slave Node') |
209 kind=wx.ITEM_NORMAL, text=_('Add Slave Node')) |
159 parent.Append(help='', id=wx.ID_DELETE, |
210 parent.Append(help='', id=wx.ID_DELETE, |
160 kind=wx.ITEM_NORMAL, text='Remove Slave Node') |
211 kind=wx.ITEM_NORMAL, text=_('Remove Slave Node')) |
161 parent.AppendSeparator() |
212 parent.AppendSeparator() |
162 parent.Append(help='', id=ID_NETWORKEDITNETWORKMENUBUILDMASTER, |
213 parent.Append(help='', id=ID_NETWORKEDITNETWORKMENUBUILDMASTER, |
163 kind=wx.ITEM_NORMAL, text='Build Master Dictionary') |
214 kind=wx.ITEM_NORMAL, text=_('Build Master Dictionary')) |
164 self.Bind(wx.EVT_MENU, self.OnAddSlaveMenu, id=wx.ID_ADD) |
215 self.Bind(wx.EVT_MENU, self.OnAddSlaveMenu, id=wx.ID_ADD) |
165 self.Bind(wx.EVT_MENU, self.OnRemoveSlaveMenu, id=wx.ID_DELETE) |
216 self.Bind(wx.EVT_MENU, self.OnRemoveSlaveMenu, id=wx.ID_DELETE) |
166 ## self.Bind(wx.EVT_MENU, self.OnBuildMasterMenu, |
217 ## self.Bind(wx.EVT_MENU, self.OnBuildMasterMenu, |
167 ## id=ID_NETWORKEDITNETWORKMENUBUILDMASTER) |
218 ## id=ID_NETWORKEDITNETWORKMENUBUILDMASTER) |
168 |
219 |
169 def _init_coll_EditMenu_Items(self, parent): |
220 def _init_coll_EditMenu_Items(self, parent): |
170 parent.Append(help='', id=wx.ID_REFRESH, |
221 parent.Append(help='', id=wx.ID_REFRESH, |
171 kind=wx.ITEM_NORMAL, text='Refresh\tCTRL+R') |
222 kind=wx.ITEM_NORMAL, text=_('Refresh\tCTRL+R')) |
172 parent.AppendSeparator() |
223 parent.AppendSeparator() |
173 parent.Append(help='', id=wx.ID_UNDO, |
224 parent.Append(help='', id=wx.ID_UNDO, |
174 kind=wx.ITEM_NORMAL, text='Undo\tCTRL+Z') |
225 kind=wx.ITEM_NORMAL, text=_('Undo\tCTRL+Z')) |
175 parent.Append(help='', id=wx.ID_REDO, |
226 parent.Append(help='', id=wx.ID_REDO, |
176 kind=wx.ITEM_NORMAL, text='Redo\tCTRL+Y') |
227 kind=wx.ITEM_NORMAL, text=_('Redo\tCTRL+Y')) |
177 parent.AppendSeparator() |
228 parent.AppendSeparator() |
178 parent.Append(help='', id=ID_NETWORKEDITEDITMENUNODEINFOS, |
229 parent.Append(help='', id=ID_NETWORKEDITEDITMENUNODEINFOS, |
179 kind=wx.ITEM_NORMAL, text='Node infos') |
230 kind=wx.ITEM_NORMAL, text=_('Node infos')) |
180 parent.Append(help='', id=ID_NETWORKEDITEDITMENUDS301PROFILE, |
231 parent.Append(help='', id=ID_NETWORKEDITEDITMENUDS301PROFILE, |
181 kind=wx.ITEM_NORMAL, text='DS-301 Profile') |
232 kind=wx.ITEM_NORMAL, text=_('DS-301 Profile')) |
182 parent.Append(help='', id=ID_NETWORKEDITEDITMENUDS302PROFILE, |
233 parent.Append(help='', id=ID_NETWORKEDITEDITMENUDS302PROFILE, |
183 kind=wx.ITEM_NORMAL, text='DS-302 Profile') |
234 kind=wx.ITEM_NORMAL, text=_('DS-302 Profile')) |
184 parent.Append(help='', id=ID_NETWORKEDITEDITMENUOTHERPROFILE, |
235 parent.Append(help='', id=ID_NETWORKEDITEDITMENUOTHERPROFILE, |
185 kind=wx.ITEM_NORMAL, text='Other Profile') |
236 kind=wx.ITEM_NORMAL, text=_('Other Profile')) |
186 self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
237 self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
187 self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
238 self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
188 self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
239 self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
189 self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu, |
240 self.Bind(wx.EVT_MENU, self.OnNodeInfosMenu, |
190 id=ID_NETWORKEDITEDITMENUNODEINFOS) |
241 id=ID_NETWORKEDITEDITMENUNODEINFOS) |
195 self.Bind(wx.EVT_MENU, self.OnEditProfileMenu, |
246 self.Bind(wx.EVT_MENU, self.OnEditProfileMenu, |
196 id=ID_NETWORKEDITEDITMENUOTHERPROFILE) |
247 id=ID_NETWORKEDITEDITMENUOTHERPROFILE) |
197 |
248 |
198 def _init_coll_AddMenu_Items(self, parent): |
249 def _init_coll_AddMenu_Items(self, parent): |
199 parent.Append(help='', id=ID_NETWORKEDITADDMENUSDOSERVER, |
250 parent.Append(help='', id=ID_NETWORKEDITADDMENUSDOSERVER, |
200 kind=wx.ITEM_NORMAL, text='SDO Server') |
251 kind=wx.ITEM_NORMAL, text=_('SDO Server')) |
201 parent.Append(help='', id=ID_NETWORKEDITADDMENUSDOCLIENT, |
252 parent.Append(help='', id=ID_NETWORKEDITADDMENUSDOCLIENT, |
202 kind=wx.ITEM_NORMAL, text='SDO Client') |
253 kind=wx.ITEM_NORMAL, text=_('SDO Client')) |
203 parent.Append(help='', id=ID_NETWORKEDITADDMENUPDOTRANSMIT, |
254 parent.Append(help='', id=ID_NETWORKEDITADDMENUPDOTRANSMIT, |
204 kind=wx.ITEM_NORMAL, text='PDO Transmit') |
255 kind=wx.ITEM_NORMAL, text=_('PDO Transmit')) |
205 parent.Append(help='', id=ID_NETWORKEDITADDMENUPDORECEIVE, |
256 parent.Append(help='', id=ID_NETWORKEDITADDMENUPDORECEIVE, |
206 kind=wx.ITEM_NORMAL, text='PDO Receive') |
257 kind=wx.ITEM_NORMAL, text=_('PDO Receive')) |
207 parent.Append(help='', id=ID_NETWORKEDITADDMENUMAPVARIABLE, |
258 parent.Append(help='', id=ID_NETWORKEDITADDMENUMAPVARIABLE, |
208 kind=wx.ITEM_NORMAL, text='Map Variable') |
259 kind=wx.ITEM_NORMAL, text=_('Map Variable')) |
209 parent.Append(help='', id=ID_NETWORKEDITADDMENUUSERTYPE, |
260 parent.Append(help='', id=ID_NETWORKEDITADDMENUUSERTYPE, |
210 kind=wx.ITEM_NORMAL, text='User Type') |
261 kind=wx.ITEM_NORMAL, text=_('User Type')) |
211 self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu, |
262 self.Bind(wx.EVT_MENU, self.OnAddSDOServerMenu, |
212 id=ID_NETWORKEDITADDMENUSDOSERVER) |
263 id=ID_NETWORKEDITADDMENUSDOSERVER) |
213 self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu, |
264 self.Bind(wx.EVT_MENU, self.OnAddSDOClientMenu, |
214 id=ID_NETWORKEDITADDMENUSDOCLIENT) |
265 id=ID_NETWORKEDITADDMENUSDOCLIENT) |
215 self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu, |
266 self.Bind(wx.EVT_MENU, self.OnAddPDOTransmitMenu, |
221 self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu, |
272 self.Bind(wx.EVT_MENU, self.OnAddUserTypeMenu, |
222 id=ID_NETWORKEDITADDMENUUSERTYPE) |
273 id=ID_NETWORKEDITADDMENUUSERTYPE) |
223 |
274 |
224 def _init_coll_HelpMenu_Items(self, parent): |
275 def _init_coll_HelpMenu_Items(self, parent): |
225 parent.Append(help='', id=wx.ID_HELP, |
276 parent.Append(help='', id=wx.ID_HELP, |
226 kind=wx.ITEM_NORMAL, text='DS-301 Standard\tF1') |
277 kind=wx.ITEM_NORMAL, text=_('DS-301 Standard\tF1')) |
227 self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, id=wx.ID_HELP) |
278 self.Bind(wx.EVT_MENU, self.OnHelpDS301Menu, id=wx.ID_HELP) |
228 parent.Append(help='', id=wx.ID_HELP_CONTEXT, |
279 parent.Append(help='', id=wx.ID_HELP_CONTEXT, |
229 kind=wx.ITEM_NORMAL, text='CAN Festival Docs\tF2') |
280 kind=wx.ITEM_NORMAL, text=_('CAN Festival Docs\tF2')) |
230 self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, id=wx.ID_HELP_CONTEXT) |
281 self.Bind(wx.EVT_MENU, self.OnHelpCANFestivalMenu, id=wx.ID_HELP_CONTEXT) |
231 if Html_Window and self.ModeSolo: |
282 if Html_Window and self.ModeSolo: |
232 parent.Append(help='', id=wx.ID_ABOUT, |
283 parent.Append(help='', id=wx.ID_ABOUT, |
233 kind=wx.ITEM_NORMAL, text='About') |
284 kind=wx.ITEM_NORMAL, text=_('About')) |
234 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
285 self.Bind(wx.EVT_MENU, self.OnAboutMenu, id=wx.ID_ABOUT) |
235 |
286 |
236 def _init_coll_HelpBar_Fields(self, parent): |
287 def _init_coll_HelpBar_Fields(self, parent): |
237 parent.SetFieldsCount(3) |
288 parent.SetFieldsCount(3) |
238 |
289 |
574 window = self.NetworkNodes.GetPage(selected) |
625 window = self.NetworkNodes.GetPage(selected) |
575 selection = window.GetSelection() |
626 selection = window.GetSelection() |
576 if selection: |
627 if selection: |
577 index, subIndex = selection |
628 index, subIndex = selection |
578 if self.NodeList.IsCurrentEntry(index): |
629 if self.NodeList.IsCurrentEntry(index): |
579 self.HelpBar.SetStatusText("Index: 0x%04X"%index, 0) |
630 self.HelpBar.SetStatusText(_("Index: 0x%04X")%index, 0) |
580 self.HelpBar.SetStatusText("Subindex: 0x%02X"%subIndex, 1) |
631 self.HelpBar.SetStatusText(_("Subindex: 0x%02X")%subIndex, 1) |
581 entryinfos = self.NodeList.GetEntryInfos(index) |
632 entryinfos = self.NodeList.GetEntryInfos(index) |
582 name = entryinfos["name"] |
633 name = entryinfos["name"] |
583 category = "Optional" |
634 category = _("Optional") |
584 if entryinfos["need"]: |
635 if entryinfos["need"]: |
585 category = "Mandatory" |
636 category = _("Mandatory") |
586 struct = "VAR" |
637 struct = "VAR" |
587 number = "" |
638 number = "" |
588 if entryinfos["struct"] & OD_IdenticalIndexes: |
639 if entryinfos["struct"] & OD_IdenticalIndexes: |
589 number = " possibly defined %d times"%entryinfos["nbmax"] |
640 number = _(" possibly defined %d times")%entryinfos["nbmax"] |
590 if entryinfos["struct"] & OD_IdenticalSubindexes: |
641 if entryinfos["struct"] & OD_IdenticalSubindexes: |
591 struct = "REC" |
642 struct = "REC" |
592 elif entryinfos["struct"] & OD_MultipleSubindexes: |
643 elif entryinfos["struct"] & OD_MultipleSubindexes: |
593 struct = "ARRAY" |
644 struct = "ARRAY" |
594 text = "%s: %s entry of struct %s%s."%(name,category,struct,number) |
645 text = _("%s: %s entry of struct %s%s.")%(name,category,struct,number) |
595 self.HelpBar.SetStatusText(text, 2) |
646 self.HelpBar.SetStatusText(text, 2) |
596 else: |
647 else: |
597 for i in xrange(3): |
648 for i in xrange(3): |
598 self.HelpBar.SetStatusText("", i) |
649 self.HelpBar.SetStatusText("", i) |
599 else: |
650 else: |
642 length = self.AddMenu.GetMenuItemCount() |
693 length = self.AddMenu.GetMenuItemCount() |
643 for i in xrange(length-6): |
694 for i in xrange(length-6): |
644 additem = self.AddMenu.FindItemByPosition(6) |
695 additem = self.AddMenu.FindItemByPosition(6) |
645 self.AddMenu.Delete(additem.GetId()) |
696 self.AddMenu.Delete(additem.GetId()) |
646 if profile not in ("None", "DS-301"): |
697 if profile not in ("None", "DS-301"): |
647 edititem.SetText("%s Profile"%profile) |
698 edititem.SetText(_("%s Profile")%profile) |
648 edititem.Enable(True) |
699 edititem.Enable(True) |
649 self.AddMenu.AppendSeparator() |
700 self.AddMenu.AppendSeparator() |
650 for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
701 for text, indexes in self.Manager.GetCurrentSpecificMenu(): |
651 new_id = wx.NewId() |
702 new_id = wx.NewId() |
652 self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text) |
703 self.AddMenu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=text) |
653 self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id) |
704 self.Bind(wx.EVT_MENU, self.GetProfileCallBack(text), id=new_id) |
654 else: |
705 else: |
655 edititem.SetText("Other Profile") |
706 edititem.SetText(_("Other Profile")) |
656 edititem.Enable(False) |
707 edititem.Enable(False) |
657 |
708 |
658 def GetProfileCallBack(self, text): |
709 def GetProfileCallBack(self, text): |
659 def ProfileCallBack(event): |
710 def ProfileCallBack(event): |
660 self.Manager.AddSpecificEntryToCurrent(text) |
711 self.Manager.AddSpecificEntryToCurrent(text) |
745 # Editing Profiles functions |
796 # Editing Profiles functions |
746 #------------------------------------------------------------------------------- |
797 #------------------------------------------------------------------------------- |
747 |
798 |
748 def OnCommunicationMenu(self, event): |
799 def OnCommunicationMenu(self, event): |
749 dictionary,current = self.Manager.GetCurrentCommunicationLists() |
800 dictionary,current = self.Manager.GetCurrentCommunicationLists() |
750 self.EditProfile("Edit DS-301 Profile", dictionary, current) |
801 self.EditProfile(_("Edit DS-301 Profile"), dictionary, current) |
751 event.Skip() |
802 event.Skip() |
752 |
803 |
753 def OnOtherCommunicationMenu(self, event): |
804 def OnOtherCommunicationMenu(self, event): |
754 dictionary,current = self.Manager.GetCurrentDS302Lists() |
805 dictionary,current = self.Manager.GetCurrentDS302Lists() |
755 self.EditProfile("Edit DS-302 Profile", dictionary, current) |
806 self.EditProfile(_("Edit DS-302 Profile"), dictionary, current) |
756 event.Skip() |
807 event.Skip() |
757 |
808 |
758 def OnEditProfileMenu(self, event): |
809 def OnEditProfileMenu(self, event): |
759 title = "Edit %s Profile"%self.Manager.GetCurrentProfileName() |
810 title = _("Edit %s Profile")%self.Manager.GetCurrentProfileName() |
760 dictionary,current = self.Manager.GetCurrentProfileLists() |
811 dictionary,current = self.Manager.GetCurrentProfileLists() |
761 self.EditProfile(title, dictionary, current) |
812 self.EditProfile(title, dictionary, current) |
762 event.Skip() |
813 event.Skip() |
763 |
814 |
764 def EditProfile(self, title, dictionary, current): |
815 def EditProfile(self, title, dictionary, current): |
856 Max_Traceback_List_Size = 20 |
907 Max_Traceback_List_Size = 20 |
857 |
908 |
858 def Display_Exception_Dialog(e_type,e_value,e_tb): |
909 def Display_Exception_Dialog(e_type,e_value,e_tb): |
859 trcbck_lst = [] |
910 trcbck_lst = [] |
860 for i,line in enumerate(traceback.extract_tb(e_tb)): |
911 for i,line in enumerate(traceback.extract_tb(e_tb)): |
861 trcbck = " " + str(i+1) + ". " |
912 trcbck = " " + str(i+1) + _(". ") |
862 if line[0].find(os.getcwd()) == -1: |
913 if line[0].find(os.getcwd()) == -1: |
863 trcbck += "file : " + str(line[0]) + ", " |
914 trcbck += _("file : ") + str(line[0]) + _(", ") |
864 else: |
915 else: |
865 trcbck += "file : " + str(line[0][len(os.getcwd()):]) + ", " |
916 trcbck += _("file : ") + str(line[0][len(os.getcwd()):]) + _(", ") |
866 trcbck += "line : " + str(line[1]) + ", " + "function : " + str(line[2]) |
917 trcbck += _("line : ") + str(line[1]) + _(", ") + _("function : ") + str(line[2]) |
867 trcbck_lst.append(trcbck) |
918 trcbck_lst.append(trcbck) |
868 |
919 |
869 # Allow clicking.... |
920 # Allow clicking.... |
870 cap = wx.Window_GetCapture() |
921 cap = wx.Window_GetCapture() |
871 if cap: |
922 if cap: |
872 cap.ReleaseMouse() |
923 cap.ReleaseMouse() |
873 |
924 |
874 dlg = wx.SingleChoiceDialog(None, |
925 dlg = wx.SingleChoiceDialog(None, |
875 """ |
926 _(""" |
876 An error happens. |
927 An error happens. |
877 |
928 |
878 Click on OK for saving an error report. |
929 Click on OK for saving an error report. |
879 |
930 |
880 Please contact LOLITech at: |
931 Please contact LOLITech at: |
881 +33 (0)3 29 57 60 42 |
932 +33 (0)3 29 57 60 42 |
882 bugs_networkedit@lolitech.fr |
933 bugs_networkedit@lolitech.fr |
883 |
934 |
884 |
935 |
885 Error: |
936 Error: |
886 """ + |
937 """) + |
887 str(e_type) + " : " + str(e_value), |
938 str(e_type) + _(" : ") + str(e_value), |
888 "Error", |
939 _("Error"), |
889 trcbck_lst) |
940 trcbck_lst) |
890 try: |
941 try: |
891 res = (dlg.ShowModal() == wx.ID_OK) |
942 res = (dlg.ShowModal() == wx.ID_OK) |
892 finally: |
943 finally: |
893 dlg.Destroy() |
944 dlg.Destroy() |
894 |
945 |
895 return res |
946 return res |
896 |
947 |
897 def Display_Error_Dialog(e_value): |
948 def Display_Error_Dialog(e_value): |
898 message = wx.MessageDialog(None, str(e_value), "Error", wx.OK|wx.ICON_ERROR) |
949 message = wx.MessageDialog(None, str(e_value), _("Error"), wx.OK|wx.ICON_ERROR) |
899 message.ShowModal() |
950 message.ShowModal() |
900 message.Destroy() |
951 message.Destroy() |
901 |
952 |
902 def get_last_traceback(tb): |
953 def get_last_traceback(tb): |
903 while tb.tb_next: |
954 while tb.tb_next: |