29 |
29 |
30 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes |
30 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes |
31 |
31 |
32 ColSizes = [75, 250, 150, 125, 100, 60, 250] |
32 ColSizes = [75, 250, 150, 125, 100, 60, 250] |
33 ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_LEFT] |
33 ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_LEFT] |
34 AccessList = "Read Only,Write Only,Read/Write" |
34 |
35 RAccessList = "Read Only,Read/Write" |
35 def GetAccessList(write=True): |
36 BoolList = "True,False" |
36 _ = lambda x : x |
37 OptionList = "Yes,No" |
37 if write: |
|
38 return [_("Read Only"), _("Write Only"), _("Read/Write")] |
|
39 return [_("Read Only"), _("Read/Write")] |
|
40 AccessList = ",".join(GetAccessList()) |
|
41 RAccessList = ",".join(GetAccessList(False)) |
|
42 ACCESS_LIST_DICT = dict([(_(access), access) for access in GetAccessList()]) |
|
43 |
|
44 def GetBoolList(): |
|
45 _ = lambda x : x |
|
46 return [_("True"), _("False")] |
|
47 BoolList = ",".join(GetBoolList()) |
|
48 BOOL_LIST_DICT = dict([(_(bool), bool) for bool in GetBoolList()]) |
|
49 |
|
50 def GetOptionList(): |
|
51 _ = lambda x : x |
|
52 return [_("Yes"), _("No")] |
|
53 OptionList = ",".join(GetOptionList()) |
|
54 OPTION_LIST_DICT = dict([(_(option), option) for option in GetOptionList()]) |
|
55 |
|
56 [USER_TYPE, SDO_SERVER, SDO_CLIENT, |
|
57 PDO_TRANSMIT, PDO_RECEIVE, MAP_VARIABLE] = range(6) |
|
58 |
|
59 INDEXCHOICE_OPTIONS = { |
|
60 USER_TYPE: (_("User Type"), 0, "AddUserType"), |
|
61 SDO_SERVER: (_("SDO Server"), 1, "AddSDOServerToCurrent"), |
|
62 SDO_CLIENT: (_("SDO Client"), 1, "AddSDOClientToCurrent"), |
|
63 PDO_RECEIVE: (_("PDO Receive"), 1, "AddPDOReceiveToCurrent"), |
|
64 PDO_TRANSMIT: (_("PDO Transmit"), 1, "AddPDOTransmitToCurrent"), |
|
65 MAP_VARIABLE: (_("Map Variable"), 0, "AddMapVariable") |
|
66 } |
|
67 |
|
68 INDEXCHOICE_OPTIONS_DICT = dict([(translation, option) for option, (translation, object, function) in INDEXCHOICE_OPTIONS.iteritems()]) |
|
69 |
|
70 INDEXCHOICE_SECTIONS = { |
|
71 0 : [USER_TYPE], |
|
72 2 : [SDO_SERVER, SDO_CLIENT], |
|
73 3 : [PDO_RECEIVE], |
|
74 4 : [PDO_RECEIVE], |
|
75 5 : [PDO_TRANSMIT], |
|
76 6 : [PDO_TRANSMIT], |
|
77 8 : [MAP_VARIABLE], |
|
78 } |
|
79 |
|
80 def GetSubindexTableColnames(): |
|
81 _ = lambda x : x |
|
82 return [_("subindex"), _("name"), _("type"), _("value"), _("access"), _("save"), _("comment")] |
38 |
83 |
39 DictionaryOrganisation = [ |
84 DictionaryOrganisation = [ |
40 {"minIndex" : 0x0001, "maxIndex" : 0x0FFF, "name" : "Data Type Definitions"}, |
85 {"minIndex" : 0x0001, "maxIndex" : 0x0FFF, "name" : "Data Type Definitions"}, |
41 {"minIndex" : 0x1000, "maxIndex" : 0x1029, "name" : "Communication Parameters"}, |
86 {"minIndex" : 0x1000, "maxIndex" : 0x1029, "name" : "Communication Parameters"}, |
42 {"minIndex" : 0x1200, "maxIndex" : 0x12FF, "name" : "SDO Parameters"}, |
87 {"minIndex" : 0x1200, "maxIndex" : 0x12FF, "name" : "SDO Parameters"}, |
81 return len(self.colnames) |
126 return len(self.colnames) |
82 |
127 |
83 def GetNumberRows(self): |
128 def GetNumberRows(self): |
84 return len(self.data) |
129 return len(self.data) |
85 |
130 |
86 def GetColLabelValue(self, col): |
131 def GetColLabelValue(self, col, translate=True): |
87 if col < len(self.colnames): |
132 if col < len(self.colnames): |
|
133 if translate: |
|
134 return _(self.colnames[col]) |
88 return self.colnames[col] |
135 return self.colnames[col] |
89 |
136 |
90 def GetRowLabelValues(self, row): |
137 def GetRowLabelValues(self, row, translate=True): |
91 return row |
138 return row |
92 |
139 |
93 def GetValue(self, row, col): |
140 def GetValue(self, row, col): |
94 if row < self.GetNumberRows(): |
141 if row < self.GetNumberRows(): |
95 return str(self.data[row].get(self.GetColLabelValue(col), "")) |
142 colname = self.GetColLabelValue(col, False) |
|
143 value = unicode(self.data[row].get(colname, "")) |
|
144 if self.editors[row][colname] in ["access", "raccess", "bool", "option"]: |
|
145 value = _(value) |
|
146 return value |
96 |
147 |
97 def GetEditor(self, row, col): |
148 def GetEditor(self, row, col): |
98 if row < self.GetNumberRows(): |
149 if row < self.GetNumberRows(): |
99 return self.editors[row].get(self.GetColLabelValue(col), "") |
150 return self.editors[row].get(self.GetColLabelValue(col, False), "") |
100 |
151 |
101 def GetValueByName(self, row, colname): |
152 def GetValueByName(self, row, colname): |
102 return self.data[row].get(colname) |
153 return self.data[row].get(colname) |
103 |
154 |
104 def SetValue(self, row, col, value): |
155 def SetValue(self, row, col, value): |
105 if col < len(self.colnames): |
156 if col < len(self.colnames): |
106 self.data[row][self.GetColLabelValue(col)] = value |
157 colname = self.GetColLabelValue(col, False) |
|
158 if self.editors[row][colname] in ["access", "raccess"]: |
|
159 value = ACCESS_LIST_DICT[value] |
|
160 elif self.editors[row][colname] == "bool": |
|
161 value = BOOL_LIST_DICT[value] |
|
162 elif self.editors[row][colname] == "option": |
|
163 value = OPTION_LIST_DICT[value] |
|
164 self.data[row][colname] = value |
107 |
165 |
108 def ResetView(self, grid): |
166 def ResetView(self, grid): |
109 """ |
167 """ |
110 (wx.grid.Grid) -> Reset the grid view. Call this to |
168 (wx.grid.Grid) -> Reset the grid view. Call this to |
111 update the grid if rows and columns have been added or deleted |
169 update the grid if rows and columns have been added or deleted |
150 |
208 |
151 for col in range(self.GetNumberCols()): |
209 for col in range(self.GetNumberCols()): |
152 attr = wx.grid.GridCellAttr() |
210 attr = wx.grid.GridCellAttr() |
153 attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE) |
211 attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE) |
154 grid.SetColAttr(col, attr) |
212 grid.SetColAttr(col, attr) |
155 grid.SetColSize(col, ColSizes[col]) |
213 grid.SetColMinimalWidth(col, ColSizes[col]) |
|
214 grid.AutoSizeColumn(col, False) |
156 |
215 |
157 typelist = None |
216 typelist = None |
158 maplist = None |
217 maplist = None |
159 for row in range(self.GetNumberRows()): |
218 for row in range(self.GetNumberRows()): |
160 editors = self.editors[row] |
219 editors = self.editors[row] |
161 for col in range(self.GetNumberCols()): |
220 for col in range(self.GetNumberCols()): |
162 editor = None |
221 editor = None |
163 renderer = None |
222 renderer = None |
164 |
223 |
165 colname = self.GetColLabelValue(col) |
224 colname = self.GetColLabelValue(col, False) |
166 editortype = editors[colname] |
225 editortype = editors[colname] |
167 if editortype and self.Editable: |
226 if editortype and self.Editable: |
168 grid.SetReadOnly(row, col, False) |
227 grid.SetReadOnly(row, col, False) |
169 if editortype == "string": |
228 if editortype == "string": |
170 editor = wx.grid.GridCellTextEditor() |
229 editor = wx.grid.GridCellTextEditor() |
275 parent.AddGrowableCol(0) |
334 parent.AddGrowableCol(0) |
276 parent.AddGrowableRow(0) |
335 parent.AddGrowableRow(0) |
277 |
336 |
278 def _init_coll_SubindexGridMenu_Items(self, parent): |
337 def _init_coll_SubindexGridMenu_Items(self, parent): |
279 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS0, |
338 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS0, |
280 kind=wx.ITEM_NORMAL, text='Add subindexes') |
339 kind=wx.ITEM_NORMAL, text=_('Add subindexes')) |
281 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS1, |
340 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS1, |
282 kind=wx.ITEM_NORMAL, text='Delete subindexes') |
341 kind=wx.ITEM_NORMAL, text=_('Delete subindexes')) |
283 parent.AppendSeparator() |
342 parent.AppendSeparator() |
284 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS3, |
343 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS3, |
285 kind=wx.ITEM_NORMAL, text='Default value') |
344 kind=wx.ITEM_NORMAL, text=_('Default value')) |
286 if not self.Editable: |
345 if not self.Editable: |
287 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS4, |
346 parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS4, |
288 kind=wx.ITEM_NORMAL, text='Add to DCF') |
347 kind=wx.ITEM_NORMAL, text=_('Add to DCF')) |
289 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
348 self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu, |
290 id=ID_EDITINGPANELMENU1ITEMS0) |
349 id=ID_EDITINGPANELMENU1ITEMS0) |
291 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
350 self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu, |
292 id=ID_EDITINGPANELMENU1ITEMS1) |
351 id=ID_EDITINGPANELMENU1ITEMS1) |
293 self.Bind(wx.EVT_MENU, self.OnDefaultValueSubindexMenu, |
352 self.Bind(wx.EVT_MENU, self.OnDefaultValueSubindexMenu, |
296 self.Bind(wx.EVT_MENU, self.OnAddToDCFSubindexMenu, |
355 self.Bind(wx.EVT_MENU, self.OnAddToDCFSubindexMenu, |
297 id=ID_EDITINGPANELMENU1ITEMS4) |
356 id=ID_EDITINGPANELMENU1ITEMS4) |
298 |
357 |
299 def _init_coll_IndexListMenu_Items(self, parent): |
358 def _init_coll_IndexListMenu_Items(self, parent): |
300 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS0, |
359 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS0, |
301 kind=wx.ITEM_NORMAL, text='Rename') |
360 kind=wx.ITEM_NORMAL, text=_('Rename')) |
302 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS2, |
361 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS2, |
303 kind=wx.ITEM_NORMAL, text='Modify') |
362 kind=wx.ITEM_NORMAL, text=_('Modify')) |
304 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS1, |
363 parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS1, |
305 kind=wx.ITEM_NORMAL, text='Delete') |
364 kind=wx.ITEM_NORMAL, text=_('Delete')) |
306 self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu, |
365 self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu, |
307 id=ID_EDITINGPANELINDEXLISTMENUITEMS0) |
366 id=ID_EDITINGPANELINDEXLISTMENUITEMS0) |
308 self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu, |
367 self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu, |
309 id=ID_EDITINGPANELINDEXLISTMENUITEMS1) |
368 id=ID_EDITINGPANELINDEXLISTMENUITEMS1) |
310 self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu, |
369 self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu, |
380 self.OnSubindexGridCellLeftClick) |
439 self.OnSubindexGridCellLeftClick) |
381 self.SubindexGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
440 self.SubindexGrid.Bind(wx.grid.EVT_GRID_EDITOR_SHOWN, |
382 self.OnSubindexGridEditorShown) |
441 self.OnSubindexGridEditorShown) |
383 |
442 |
384 self.CallbackCheck = wx.CheckBox(id=ID_EDITINGPANELCALLBACKCHECK, |
443 self.CallbackCheck = wx.CheckBox(id=ID_EDITINGPANELCALLBACKCHECK, |
385 label='Have Callbacks', name='CallbackCheck', |
444 label=_('Have Callbacks'), name='CallbackCheck', |
386 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
445 parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152, |
387 24), style=0) |
446 24), style=0) |
388 self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck, |
447 self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck, |
389 id=ID_EDITINGPANELCALLBACKCHECK) |
448 id=ID_EDITINGPANELCALLBACKCHECK) |
390 |
449 |
393 size=wx.Size(-1, -1), style=0) |
452 size=wx.Size(-1, -1), style=0) |
394 self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick, |
453 self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick, |
395 id=ID_EDITINGPANELINDEXLIST) |
454 id=ID_EDITINGPANELINDEXLIST) |
396 self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp) |
455 self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp) |
397 |
456 |
398 self.AddButton = wx.Button(id=ID_EDITINGPANELADDBUTTON, label='Add', |
457 self.AddButton = wx.Button(id=ID_EDITINGPANELADDBUTTON, label=_('Add'), |
399 name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
458 name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0), |
400 size=wx.Size(50, 30), style=0) |
459 size=wx.DefaultSize, style=0) |
401 self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick, |
460 self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick, |
402 id=ID_EDITINGPANELADDBUTTON) |
461 id=ID_EDITINGPANELADDBUTTON) |
403 |
462 |
404 self.IndexChoice = wx.Choice(choices=[], id=ID_EDITINGPANELINDEXCHOICE, |
463 self.IndexChoice = wx.Choice(choices=[], id=ID_EDITINGPANELINDEXCHOICE, |
405 name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50, |
464 name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50, |
418 self.Index = None |
477 self.Index = None |
419 |
478 |
420 for values in DictionaryOrganisation: |
479 for values in DictionaryOrganisation: |
421 text = " 0x%04X-0x%04X %s"%(values["minIndex"], values["maxIndex"], values["name"]) |
480 text = " 0x%04X-0x%04X %s"%(values["minIndex"], values["maxIndex"], values["name"]) |
422 self.PartList.Append(text) |
481 self.PartList.Append(text) |
423 self.Table = SubindexTable(self, [], [], ["subindex", "name", "type", "value", "access", "save", "comment"]) |
482 self.Table = SubindexTable(self, [], [], GetSubindexTableColnames()) |
424 self.SubindexGrid.SetTable(self.Table) |
483 self.SubindexGrid.SetTable(self.Table) |
425 self.SubindexGrid.SetRowLabelSize(0) |
484 self.SubindexGrid.SetRowLabelSize(0) |
426 self.CallbackCheck.Disable() |
485 self.CallbackCheck.Disable() |
427 self.Table.ResetView(self.SubindexGrid) |
486 self.Table.ResetView(self.SubindexGrid) |
428 |
487 |
487 def OnAddButtonClick(self, event): |
546 def OnAddButtonClick(self, event): |
488 if self.Editable: |
547 if self.Editable: |
489 self.SubindexGrid.SetGridCursor(0, 0) |
548 self.SubindexGrid.SetGridCursor(0, 0) |
490 selected = self.IndexChoice.GetStringSelection() |
549 selected = self.IndexChoice.GetStringSelection() |
491 if selected != "": |
550 if selected != "": |
492 if selected == "User Type": |
551 choice = INDEXCHOICE_OPTIONS_DICT.get(selected, None) |
493 self.ParentWindow.AddUserType() |
552 if choice is not None: |
494 elif selected == "SDO Server": |
553 if INDEXCHOICE_OPTIONS[choice][1] == 0: |
495 self.Manager.AddSDOServerToCurrent() |
554 getattr(self.ParentWindow, INDEXCHOICE_OPTIONS[choice][2])() |
496 elif selected == "SDO Client": |
555 elif INDEXCHOICE_OPTIONS[choice][1] == 1: |
497 self.Manager.AddSDOClientToCurrent() |
556 getattr(self.Manager, INDEXCHOICE_OPTIONS[choice][2])() |
498 elif selected == "PDO Receive": |
|
499 self.Manager.AddPDOReceiveToCurrent() |
|
500 elif selected == "PDO Transmit": |
|
501 self.Manager.AddPDOTransmitToCurrent() |
|
502 elif selected == "Map Variable": |
|
503 self.ParentWindow.AddMapVariable() |
|
504 elif selected in [menu for menu, indexes in self.Manager.GetCurrentSpecificMenu()]: |
557 elif selected in [menu for menu, indexes in self.Manager.GetCurrentSpecificMenu()]: |
505 self.Manager.AddSpecificEntryToCurrent(selected) |
558 self.Manager.AddSpecificEntryToCurrent(selected) |
506 else: |
559 else: |
507 index = self.ChoiceIndex[self.IndexChoice.GetSelection()] |
560 index = self.ChoiceIndex[self.IndexChoice.GetSelection()] |
508 self.Manager.ManageEntriesOfCurrent([index], []) |
561 self.Manager.ManageEntriesOfCurrent([index], []) |
546 for name, index in self.Manager.GetCurrentValidIndexes(values["minIndex"], values["maxIndex"]): |
599 for name, index in self.Manager.GetCurrentValidIndexes(values["minIndex"], values["maxIndex"]): |
547 self.IndexList.Append("0x%04X %s"%(index, name)) |
600 self.IndexList.Append("0x%04X %s"%(index, name)) |
548 self.ListIndex.append(index) |
601 self.ListIndex.append(index) |
549 if self.Editable: |
602 if self.Editable: |
550 self.ChoiceIndex = [] |
603 self.ChoiceIndex = [] |
551 if i == 0: |
604 choices = INDEXCHOICE_SECTIONS.get(i, None) |
552 self.IndexChoice.Append("User Type") |
605 if choices is not None: |
553 self.IndexChoice.SetStringSelection("User Type") |
606 for c in choices: |
554 elif i == 2: |
607 self.IndexChoice.Append(INDEXCHOICE_OPTIONS[c][0]) |
555 self.IndexChoice.Append("SDO Server") |
608 if len(choices) > 1: |
556 self.IndexChoice.Append("SDO Client") |
609 if choiceindex != wx.NOT_FOUND and choice == self.IndexChoice.GetString(choiceindex): |
557 if choiceindex != wx.NOT_FOUND and choice == self.IndexChoice.GetString(choiceindex): |
610 self.IndexChoice.SetStringSelection(choice) |
558 self.IndexChoice.SetStringSelection(choice) |
611 else: |
559 elif i in (3, 4): |
612 self.IndexChoice.SetSelection(0) |
560 self.IndexChoice.Append("PDO Receive") |
|
561 self.IndexChoice.SetStringSelection("PDO Receive") |
|
562 elif i in (5, 6): |
|
563 self.IndexChoice.Append("PDO Transmit") |
|
564 self.IndexChoice.SetStringSelection("PDO Transmit") |
|
565 elif i == 8: |
|
566 self.IndexChoice.Append("Map Variable") |
|
567 self.IndexChoice.SetStringSelection("Map Variable") |
|
568 else: |
613 else: |
569 for name, index in self.Manager.GetCurrentValidChoices(values["minIndex"], values["maxIndex"]): |
614 for name, index in self.Manager.GetCurrentValidChoices(values["minIndex"], values["maxIndex"]): |
570 if index: |
615 if index: |
571 self.IndexChoice.Append("0x%04X %s"%(index, name)) |
616 self.IndexChoice.Append("0x%04X %s"%(index, name)) |
572 else: |
617 else: |
757 selected = self.IndexList.GetSelection() |
802 selected = self.IndexList.GetSelection() |
758 if selected != wx.NOT_FOUND: |
803 if selected != wx.NOT_FOUND: |
759 index = self.ListIndex[selected] |
804 index = self.ListIndex[selected] |
760 if self.Manager.IsCurrentEntry(index): |
805 if self.Manager.IsCurrentEntry(index): |
761 infos = self.Manager.GetEntryInfos(index) |
806 infos = self.Manager.GetEntryInfos(index) |
762 dialog = wx.TextEntryDialog(self, "Give a new name for index 0x%04X"%index, |
807 dialog = wx.TextEntryDialog(self, _("Give a new name for index 0x%04X")%index, |
763 "Rename an index", infos["name"], wx.OK|wx.CANCEL) |
808 _("Rename an index"), infos["name"], wx.OK|wx.CANCEL) |
764 if dialog.ShowModal() == wx.ID_OK: |
809 if dialog.ShowModal() == wx.ID_OK: |
765 self.Manager.SetCurrentEntryName(index, dialog.GetValue()) |
810 self.Manager.SetCurrentEntryName(index, dialog.GetValue()) |
766 self.ParentWindow.RefreshBufferState() |
811 self.ParentWindow.RefreshBufferState() |
767 self.RefreshIndexList() |
812 self.RefreshIndexList() |
768 dialog.Destroy() |
813 dialog.Destroy() |
803 if self.Editable: |
848 if self.Editable: |
804 selected = self.IndexList.GetSelection() |
849 selected = self.IndexList.GetSelection() |
805 if selected != wx.NOT_FOUND: |
850 if selected != wx.NOT_FOUND: |
806 index = self.ListIndex[selected] |
851 index = self.ListIndex[selected] |
807 if self.Manager.IsCurrentEntry(index): |
852 if self.Manager.IsCurrentEntry(index): |
808 dialog = wx.TextEntryDialog(self, "Number of subindexes to add:", |
853 dialog = wx.TextEntryDialog(self, _("Number of subindexes to add:"), |
809 "Add subindexes", "1", wx.OK|wx.CANCEL) |
854 _("Add subindexes"), "1", wx.OK|wx.CANCEL) |
810 if dialog.ShowModal() == wx.ID_OK: |
855 if dialog.ShowModal() == wx.ID_OK: |
811 try: |
856 try: |
812 number = int(dialog.GetValue()) |
857 number = int(dialog.GetValue()) |
813 self.Manager.AddSubentriesToCurrent(index, number) |
858 self.Manager.AddSubentriesToCurrent(index, number) |
814 self.ParentWindow.RefreshBufferState() |
859 self.ParentWindow.RefreshBufferState() |
815 self.RefreshIndexList() |
860 self.RefreshIndexList() |
816 except: |
861 except: |
817 message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR) |
862 message = wx.MessageDialog(self, _("An integer is required!"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
818 message.ShowModal() |
863 message.ShowModal() |
819 message.Destroy() |
864 message.Destroy() |
820 dialog.Destroy() |
865 dialog.Destroy() |
821 event.Skip() |
866 event.Skip() |
822 |
867 |
824 if self.Editable: |
869 if self.Editable: |
825 selected = self.IndexList.GetSelection() |
870 selected = self.IndexList.GetSelection() |
826 if selected != wx.NOT_FOUND: |
871 if selected != wx.NOT_FOUND: |
827 index = self.ListIndex[selected] |
872 index = self.ListIndex[selected] |
828 if self.Manager.IsCurrentEntry(index): |
873 if self.Manager.IsCurrentEntry(index): |
829 dialog = wx.TextEntryDialog(self, "Number of subindexes to delete:", |
874 dialog = wx.TextEntryDialog(self, _("Number of subindexes to delete:"), |
830 "Delete subindexes", "1", wx.OK|wx.CANCEL) |
875 _("Delete subindexes"), "1", wx.OK|wx.CANCEL) |
831 if dialog.ShowModal() == wx.ID_OK: |
876 if dialog.ShowModal() == wx.ID_OK: |
832 try: |
877 try: |
833 number = int(dialog.GetValue()) |
878 number = int(dialog.GetValue()) |
834 self.Manager.RemoveSubentriesFromCurrent(index, number) |
879 self.Manager.RemoveSubentriesFromCurrent(index, number) |
835 self.ParentWindow.RefreshBufferState() |
880 self.ParentWindow.RefreshBufferState() |
836 self.RefreshIndexList() |
881 self.RefreshIndexList() |
837 except: |
882 except: |
838 message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR) |
883 message = wx.MessageDialog(self, _("An integer is required!"), _("ERROR"), wx.OK|wx.ICON_ERROR) |
839 message.ShowModal() |
884 message.ShowModal() |
840 message.Destroy() |
885 message.Destroy() |
841 dialog.Destroy() |
886 dialog.Destroy() |
842 event.Skip() |
887 event.Skip() |
843 |
888 |