objdictgen/subindextable.py
changeset 254 f2b0acb54e65
parent 243 7fcc129a06ce
child 266 8678a3cf7fe7
equal deleted inserted replaced
253:bf58ce630b88 254:f2b0acb54e65
    19 #
    19 #
    20 #You should have received a copy of the GNU Lesser General Public
    20 #You should have received a copy of the GNU Lesser General Public
    21 #License along with this library; if not, write to the Free Software
    21 #License along with this library; if not, write to the Free Software
    22 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    22 #Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    23 
    23 
    24 from wxPython.wx import *
       
    25 from wxPython.grid import *
       
    26 import wx
    24 import wx
    27 import wx.grid
    25 import wx.grid
    28 
    26 
    29 from types import *
    27 from types import *
    30 
    28 
    31 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
    29 from node import OD_Subindex, OD_MultipleSubindexes, OD_IdenticalSubindexes, OD_IdenticalIndexes
    32 
    30 
    33 ColSizes = [75, 250, 150, 125, 100, 60, 250]
    31 ColSizes = [75, 250, 150, 125, 100, 60, 250]
    34 ColAlignements = [wxALIGN_CENTER, wxALIGN_LEFT, wxALIGN_CENTER, wxALIGN_RIGHT, wxALIGN_CENTER, wxALIGN_CENTER, wxALIGN_LEFT]
    32 ColAlignements = [wx.ALIGN_CENTER, wx.ALIGN_LEFT, wx.ALIGN_CENTER, wx.ALIGN_RIGHT, wx.ALIGN_CENTER, wx.ALIGN_CENTER, wx.ALIGN_LEFT]
    35 AccessList = "Read Only,Write Only,Read/Write"
    33 AccessList = "Read Only,Write Only,Read/Write"
    36 RAccessList = "Read Only,Read/Write"
    34 RAccessList = "Read Only,Read/Write"
    37 BoolList = "True,False"
    35 BoolList = "True,False"
    38 OptionList = "Yes,No"
    36 OptionList = "Yes,No"
    39 
    37 
    50     {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
    48     {"minIndex" : 0x6000, "maxIndex" : 0x9FFF, "name" : "Standardized Device Profile"},
    51     {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
    49     {"minIndex" : 0xA000, "maxIndex" : 0xBFFF, "name" : "Standardized Interface Profile"}]
    52 
    50 
    53 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
    51 SizeConversion = {1 : "X", 8 : "B", 16 : "W", 24 : "D", 32 : "D", 40 : "L", 48 : "L", 56 : "L", 64 : "L"}
    54 
    52 
    55 class SubindexTable(wxPyGridTableBase):
    53 class SubindexTable(wx.grid.PyGridTableBase):
    56     
    54     
    57     """
    55     """
    58     A custom wxGrid Table using user supplied data
    56     A custom wxGrid Table using user supplied data
    59     """
    57     """
    60     def __init__(self, parent, data, editors, colnames):
    58     def __init__(self, parent, data, editors, colnames):
    61         # The base class must be initialized *first*
    59         # The base class must be initialized *first*
    62         wxPyGridTableBase.__init__(self)
    60         wx.grid.PyGridTableBase.__init__(self)
    63         self.data = data
    61         self.data = data
    64         self.editors = editors
    62         self.editors = editors
    65         self.CurrentIndex = 0
    63         self.CurrentIndex = 0
    66         self.colnames = colnames
    64         self.colnames = colnames
    67         self.Parent = parent
    65         self.Parent = parent
   110         if col < len(self.colnames):
   108         if col < len(self.colnames):
   111             self.data[row][self.GetColLabelValue(col)] = value
   109             self.data[row][self.GetColLabelValue(col)] = value
   112         
   110         
   113     def ResetView(self, grid):
   111     def ResetView(self, grid):
   114         """
   112         """
   115         (wxGrid) -> Reset the grid view.   Call this to
   113         (wx.grid.Grid) -> Reset the grid view.   Call this to
   116         update the grid if rows and columns have been added or deleted
   114         update the grid if rows and columns have been added or deleted
   117         """
   115         """
   118         grid.BeginBatch()
   116         grid.BeginBatch()
   119         for current, new, delmsg, addmsg in [
   117         for current, new, delmsg, addmsg in [
   120             (self._rows, self.GetNumberRows(), wxGRIDTABLE_NOTIFY_ROWS_DELETED, wxGRIDTABLE_NOTIFY_ROWS_APPENDED),
   118             (self._rows, self.GetNumberRows(), wx.grid.GRIDTABLE_NOTIFY_ROWS_DELETED, wx.grid.GRIDTABLE_NOTIFY_ROWS_APPENDED),
   121             (self._cols, self.GetNumberCols(), wxGRIDTABLE_NOTIFY_COLS_DELETED, wxGRIDTABLE_NOTIFY_COLS_APPENDED),
   119             (self._cols, self.GetNumberCols(), wx.grid.GRIDTABLE_NOTIFY_COLS_DELETED, wx.grid.GRIDTABLE_NOTIFY_COLS_APPENDED),
   122         ]:
   120         ]:
   123             if new < current:
   121             if new < current:
   124                 msg = wxGridTableMessage(self,delmsg,new,current-new)
   122                 msg = wx.grid.GridTableMessage(self,delmsg,new,current-new)
   125                 grid.ProcessTableMessage(msg)
   123                 grid.ProcessTableMessage(msg)
   126             elif new > current:
   124             elif new > current:
   127                 msg = wxGridTableMessage(self,addmsg,new-current)
   125                 msg = wx.grid.GridTableMessage(self,addmsg,new-current)
   128                 grid.ProcessTableMessage(msg)
   126                 grid.ProcessTableMessage(msg)
   129                 self.UpdateValues(grid)
   127                 self.UpdateValues(grid)
   130         grid.EndBatch()
   128         grid.EndBatch()
   131 
   129 
   132         self._rows = self.GetNumberRows()
   130         self._rows = self.GetNumberRows()
   140 
   138 
   141 
   139 
   142     def UpdateValues(self, grid):
   140     def UpdateValues(self, grid):
   143         """Update all displayed values"""
   141         """Update all displayed values"""
   144         # This sends an event to the grid table to update all of the values
   142         # This sends an event to the grid table to update all of the values
   145         msg = wxGridTableMessage(self, wxGRIDTABLE_REQUEST_VIEW_GET_VALUES)
   143         msg = wx.grid.GridTableMessage(self, wx.grid.GRIDTABLE_REQUEST_VIEW_GET_VALUES)
   146         grid.ProcessTableMessage(msg)
   144         grid.ProcessTableMessage(msg)
   147 
   145 
   148     def _updateColAttrs(self, grid):
   146     def _updateColAttrs(self, grid):
   149         """
   147         """
   150         wxGrid -> update the column attributes to add the
   148         wx.grid.Grid -> update the column attributes to add the
   151         appropriate renderer given the column name.
   149         appropriate renderer given the column name.
   152 
   150 
   153         Otherwise default to the default renderer.
   151         Otherwise default to the default renderer.
   154         """
   152         """
   155         
   153         
   156         for col in range(self.GetNumberCols()):
   154         for col in range(self.GetNumberCols()):
   157             attr = wxGridCellAttr()
   155             attr = wx.grid.GridCellAttr()
   158             attr.SetAlignment(ColAlignements[col], wxALIGN_CENTRE)
   156             attr.SetAlignment(ColAlignements[col], wx.ALIGN_CENTRE)
   159             grid.SetColAttr(col, attr)
   157             grid.SetColAttr(col, attr)
   160             grid.SetColSize(col, ColSizes[col])
   158             grid.SetColSize(col, ColSizes[col])
   161         
   159         
   162         typelist = None
   160         typelist = None
   163         maplist = None
   161         maplist = None
   170                 colname = self.GetColLabelValue(col)
   168                 colname = self.GetColLabelValue(col)
   171                 editortype = editors[colname]
   169                 editortype = editors[colname]
   172                 if editortype and self.Editable:
   170                 if editortype and self.Editable:
   173                     grid.SetReadOnly(row, col, False)
   171                     grid.SetReadOnly(row, col, False)
   174                     if editortype == "string":
   172                     if editortype == "string":
   175                         editor = wxGridCellTextEditor()
   173                         editor = wx.grid.GridCellTextEditor()
   176                         renderer = wxGridCellStringRenderer()
   174                         renderer = wx.grid.GridCellStringRenderer()
   177                         if colname == "value" and "length" in editors:
   175                         if colname == "value" and "length" in editors:
   178                             editor.SetParameters(editors["length"]) 
   176                             editor.SetParameters(editors["length"]) 
   179                     elif editortype == "number":
   177                     elif editortype == "number":
   180                         editor = wxGridCellNumberEditor()
   178                         editor = wx.grid.GridCellNumberEditor()
   181                         renderer = wxGridCellNumberRenderer()
   179                         renderer = wx.grid.GridCellNumberRenderer()
   182                         if colname == "value" and "min" in editors and "max" in editors:
   180                         if colname == "value" and "min" in editors and "max" in editors:
   183                             editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
   181                             editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
   184                     elif editortype == "real":
   182                     elif editortype == "real":
   185                         editor = wxGridCellFloatEditor()
   183                         editor = wx.grid.GridCellFloatEditor()
   186                         renderer = wxGridCellFloatRenderer()
   184                         renderer = wx.grid.GridCellFloatRenderer()
   187                         if colname == "value" and "min" in editors and "max" in editors:
   185                         if colname == "value" and "min" in editors and "max" in editors:
   188                             editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
   186                             editor.SetParameters("%s,%s"%(editors["min"],editors["max"]))
   189                     elif editortype == "bool":
   187                     elif editortype == "bool":
   190                         editor = wxGridCellChoiceEditor()
   188                         editor = wx.grid.GridCellChoiceEditor()
   191                         editor.SetParameters(BoolList)
   189                         editor.SetParameters(BoolList)
   192                     elif editortype == "access":
   190                     elif editortype == "access":
   193                         editor = wxGridCellChoiceEditor()
   191                         editor = wx.grid.GridCellChoiceEditor()
   194                         editor.SetParameters(AccessList)
   192                         editor.SetParameters(AccessList)
   195                     elif editortype == "raccess":
   193                     elif editortype == "raccess":
   196                         editor = wxGridCellChoiceEditor()
   194                         editor = wx.grid.GridCellChoiceEditor()
   197                         editor.SetParameters(RAccessList)
   195                         editor.SetParameters(RAccessList)
   198                     elif editortype == "option":
   196                     elif editortype == "option":
   199                         editor = wxGridCellChoiceEditor()
   197                         editor = wx.grid.GridCellChoiceEditor()
   200                         editor.SetParameters(OptionList)
   198                         editor.SetParameters(OptionList)
   201                     elif editortype == "type":
   199                     elif editortype == "type":
   202                         editor = wxGridCellChoiceEditor()
   200                         editor = wx.grid.GridCellChoiceEditor()
   203                         if typelist == None:
   201                         if typelist == None:
   204                             typelist = self.Parent.Manager.GetCurrentTypeList()
   202                             typelist = self.Parent.Manager.GetCurrentTypeList()
   205                         editor.SetParameters(typelist)
   203                         editor.SetParameters(typelist)
   206                     elif editortype == "map":
   204                     elif editortype == "map":
   207                         editor = wxGridCellChoiceEditor()
   205                         editor = wx.grid.GridCellChoiceEditor()
   208                         if maplist == None:
   206                         if maplist == None:
   209                             maplist = self.Parent.Manager.GetCurrentMapList()
   207                             maplist = self.Parent.Manager.GetCurrentMapList()
   210                         editor.SetParameters(maplist)
   208                         editor.SetParameters(maplist)
   211                     elif editortype == "time":
   209                     elif editortype == "time":
   212                         editor = wxGridCellTextEditor()
   210                         editor = wx.grid.GridCellTextEditor()
   213                         renderer = wxGridCellStringRenderer()
   211                         renderer = wx.grid.GridCellStringRenderer()
   214                     elif editortype == "domain":
   212                     elif editortype == "domain":
   215                         editor = wxGridCellTextEditor()
   213                         editor = wx.grid.GridCellTextEditor()
   216                         renderer = wxGridCellStringRenderer()
   214                         renderer = wx.grid.GridCellStringRenderer()
   217                 else:
   215                 else:
   218                     grid.SetReadOnly(row, col, True)
   216                     grid.SetReadOnly(row, col, True)
   219                     
   217                     
   220                 grid.SetCellEditor(row, col, editor)
   218                 grid.SetCellEditor(row, col, editor)
   221                 grid.SetCellRenderer(row, col, renderer)
   219                 grid.SetCellRenderer(row, col, renderer)
   222                 
   220                 
   223                 grid.SetCellBackgroundColour(row, col, wxWHITE)
   221                 grid.SetCellBackgroundColour(row, col, wx.WHITE)
   224     
   222     
   225     def SetData(self, data):
   223     def SetData(self, data):
   226         self.data = data
   224         self.data = data
   227         
   225         
   228     def SetEditors(self, editors):
   226     def SetEditors(self, editors):
   239 
   237 
   240     def Empty(self):
   238     def Empty(self):
   241         self.data = []
   239         self.data = []
   242         self.editors = []
   240         self.editors = []
   243 
   241 
   244 [wxID_EDITINGPANEL, wxID_EDITINGPANELADDBUTTON, wxID_EDITINGPANELINDEXCHOICE, 
   242 [ID_EDITINGPANEL, ID_EDITINGPANELADDBUTTON, ID_EDITINGPANELINDEXCHOICE, 
   245  wxID_EDITINGPANELINDEXLIST, wxID_EDITINGPANELINDEXLISTPANEL, wxID_EDITINGPANELPARTLIST, 
   243  ID_EDITINGPANELINDEXLIST, ID_EDITINGPANELINDEXLISTPANEL, ID_EDITINGPANELPARTLIST, 
   246  wxID_EDITINGPANELSECONDSPLITTER, wxID_EDITINGPANELSUBINDEXGRID,
   244  ID_EDITINGPANELSECONDSPLITTER, ID_EDITINGPANELSUBINDEXGRID,
   247  wxID_EDITINGPANELSUBINDEXGRIDPANEL, wxID_EDITINGPANELCALLBACKCHECK,
   245  ID_EDITINGPANELSUBINDEXGRIDPANEL, ID_EDITINGPANELCALLBACKCHECK,
   248 ] = [wx.NewId() for _init_ctrls in range(10)]
   246 ] = [wx.NewId() for _init_ctrls in range(10)]
   249 
   247 
   250 [wxID_EDITINGPANELINDEXLISTMENUITEMS0, wxID_EDITINGPANELINDEXLISTMENUITEMS1, 
   248 [ID_EDITINGPANELINDEXLISTMENUITEMS0, ID_EDITINGPANELINDEXLISTMENUITEMS1, 
   251  wxID_EDITINGPANELINDEXLISTMENUITEMS2, 
   249  ID_EDITINGPANELINDEXLISTMENUITEMS2, 
   252 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)]
   250 ] = [wx.NewId() for _init_coll_IndexListMenu_Items in range(3)]
   253 
   251 
   254 [wxID_EDITINGPANELMENU1ITEMS0, wxID_EDITINGPANELMENU1ITEMS1, 
   252 [ID_EDITINGPANELMENU1ITEMS0, ID_EDITINGPANELMENU1ITEMS1, 
   255 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)]
   253 ] = [wx.NewId() for _init_coll_SubindexGridMenu_Items in range(2)]
   256 
   254 
   257 class EditingPanel(wx.SplitterWindow):
   255 class EditingPanel(wx.SplitterWindow):
   258     def _init_coll_AddToListSizer_Items(self, parent):
   256     def _init_coll_AddToListSizer_Items(self, parent):
   259         # generated method, don't edit
       
   260 
       
   261         parent.AddWindow(self.AddButton, 0, border=0, flag=0)
   257         parent.AddWindow(self.AddButton, 0, border=0, flag=0)
   262         parent.AddWindow(self.IndexChoice, 0, border=0, flag=wxGROW)
   258         parent.AddWindow(self.IndexChoice, 0, border=0, flag=wx.GROW)
   263 
   259 
   264     def _init_coll_SubindexGridSizer_Items(self, parent):
   260     def _init_coll_SubindexGridSizer_Items(self, parent):
   265         # generated method, don't edit
       
   266 
       
   267         parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0)
   261         parent.AddWindow(self.CallbackCheck, 0, border=0, flag=0)
   268         parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wxGROW)
   262         parent.AddWindow(self.SubindexGrid, 0, border=0, flag=wx.GROW)
   269 
   263 
   270     def _init_coll_IndexListSizer_Items(self, parent):
   264     def _init_coll_IndexListSizer_Items(self, parent):
   271         # generated method, don't edit
   265         parent.AddWindow(self.IndexList, 0, border=0, flag=wx.GROW)
   272 
   266         parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wx.GROW)
   273         parent.AddWindow(self.IndexList, 0, border=0, flag=wxGROW)
       
   274         parent.AddSizer(self.AddToListSizer, 0, border=0, flag=wxGROW)
       
   275 
   267 
   276     def _init_coll_AddToListSizer_Growables(self, parent):
   268     def _init_coll_AddToListSizer_Growables(self, parent):
   277         # generated method, don't edit
       
   278 
       
   279         parent.AddGrowableCol(1)
   269         parent.AddGrowableCol(1)
   280 
   270 
   281     def _init_coll_SubindexGridSizer_Growables(self, parent):
   271     def _init_coll_SubindexGridSizer_Growables(self, parent):
   282         # generated method, don't edit
       
   283 
       
   284         parent.AddGrowableCol(0)
   272         parent.AddGrowableCol(0)
   285         parent.AddGrowableRow(1)
   273         parent.AddGrowableRow(1)
   286 
   274 
   287     def _init_coll_IndexListSizer_Growables(self, parent):
   275     def _init_coll_IndexListSizer_Growables(self, parent):
   288         # generated method, don't edit
       
   289 
       
   290         parent.AddGrowableCol(0)
   276         parent.AddGrowableCol(0)
   291         parent.AddGrowableRow(0)
   277         parent.AddGrowableRow(0)
   292 
   278 
   293     def _init_coll_SubindexGridMenu_Items(self, parent):
   279     def _init_coll_SubindexGridMenu_Items(self, parent):
   294         # generated method, don't edit
   280         parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS0,
   295 
       
   296         parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS0,
       
   297               kind=wx.ITEM_NORMAL, text='Add')
   281               kind=wx.ITEM_NORMAL, text='Add')
   298         parent.Append(help='', id=wxID_EDITINGPANELMENU1ITEMS1,
   282         parent.Append(help='', id=ID_EDITINGPANELMENU1ITEMS1,
   299               kind=wx.ITEM_NORMAL, text='Delete')
   283               kind=wx.ITEM_NORMAL, text='Delete')
   300         self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu,
   284         self.Bind(wx.EVT_MENU, self.OnAddSubindexMenu,
   301               id=wxID_EDITINGPANELMENU1ITEMS0)
   285               id=ID_EDITINGPANELMENU1ITEMS0)
   302         self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu,
   286         self.Bind(wx.EVT_MENU, self.OnDeleteSubindexMenu,
   303               id=wxID_EDITINGPANELMENU1ITEMS1)
   287               id=ID_EDITINGPANELMENU1ITEMS1)
   304 
   288 
   305     def _init_coll_IndexListMenu_Items(self, parent):
   289     def _init_coll_IndexListMenu_Items(self, parent):
   306         # generated method, don't edit
   290         parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS0,
   307 
       
   308         parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS0,
       
   309               kind=wx.ITEM_NORMAL, text='Rename')
   291               kind=wx.ITEM_NORMAL, text='Rename')
   310         parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS2,
   292         parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS2,
   311               kind=wx.ITEM_NORMAL, text='Modify')
   293               kind=wx.ITEM_NORMAL, text='Modify')
   312         parent.Append(help='', id=wxID_EDITINGPANELINDEXLISTMENUITEMS1,
   294         parent.Append(help='', id=ID_EDITINGPANELINDEXLISTMENUITEMS1,
   313               kind=wx.ITEM_NORMAL, text='Delete')
   295               kind=wx.ITEM_NORMAL, text='Delete')
   314         self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu,
   296         self.Bind(wx.EVT_MENU, self.OnRenameIndexMenu,
   315               id=wxID_EDITINGPANELINDEXLISTMENUITEMS0)
   297               id=ID_EDITINGPANELINDEXLISTMENUITEMS0)
   316         self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu,
   298         self.Bind(wx.EVT_MENU, self.OnDeleteIndexMenu,
   317               id=wxID_EDITINGPANELINDEXLISTMENUITEMS1)
   299               id=ID_EDITINGPANELINDEXLISTMENUITEMS1)
   318         self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu,
   300         self.Bind(wx.EVT_MENU, self.OnModifyIndexMenu,
   319               id=wxID_EDITINGPANELINDEXLISTMENUITEMS2)
   301               id=ID_EDITINGPANELINDEXLISTMENUITEMS2)
   320 
   302 
   321     def _init_utils(self):
   303     def _init_utils(self):
   322         # generated method, don't edit
       
   323         self.IndexListMenu = wx.Menu(title='')
   304         self.IndexListMenu = wx.Menu(title='')
   324 
       
   325         self.SubindexGridMenu = wx.Menu(title='')
   305         self.SubindexGridMenu = wx.Menu(title='')
   326 
   306 
   327         self._init_coll_IndexListMenu_Items(self.IndexListMenu)
   307         self._init_coll_IndexListMenu_Items(self.IndexListMenu)
   328         self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu)
   308         self._init_coll_SubindexGridMenu_Items(self.SubindexGridMenu)
   329 
   309 
   330     def _init_sizers(self):
   310     def _init_sizers(self):
   331         # generated method, don't edit
       
   332         self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   311         self.IndexListSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   333 
       
   334         self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   312         self.SubindexGridSizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
   335 
       
   336         self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
   313         self.AddToListSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
   337 
   314 
   338         self._init_coll_IndexListSizer_Growables(self.IndexListSizer)
   315         self._init_coll_IndexListSizer_Growables(self.IndexListSizer)
   339         self._init_coll_IndexListSizer_Items(self.IndexListSizer)
   316         self._init_coll_IndexListSizer_Items(self.IndexListSizer)
   340         self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer)
   317         self._init_coll_SubindexGridSizer_Growables(self.SubindexGridSizer)
   344 
   321 
   345         self.SubindexGridPanel.SetSizer(self.SubindexGridSizer)
   322         self.SubindexGridPanel.SetSizer(self.SubindexGridSizer)
   346         self.IndexListPanel.SetSizer(self.IndexListSizer)
   323         self.IndexListPanel.SetSizer(self.IndexListSizer)
   347         
   324         
   348     def _init_ctrls(self, prnt):
   325     def _init_ctrls(self, prnt):
   349         wx.SplitterWindow.__init__(self, id=wxID_EDITINGPANEL,
   326         wx.SplitterWindow.__init__(self, id=ID_EDITINGPANEL,
   350               name='MainSplitter', parent=prnt, point=wx.Point(0, 0),
   327               name='MainSplitter', parent=prnt, point=wx.Point(0, 0),
   351               size=wx.Size(-1, -1), style=wx.SP_3D)
   328               size=wx.Size(-1, -1), style=wx.SP_3D)
   352         self._init_utils()
   329         self._init_utils()
   353         self.SetNeedUpdating(True)
   330         self.SetNeedUpdating(True)
   354         self.SetMinimumPaneSize(1)
   331         self.SetMinimumPaneSize(1)
   355 
   332 
   356         self.PartList = wx.ListBox(choices=[], id=wxID_EDITINGPANELPARTLIST,
   333         self.PartList = wx.ListBox(choices=[], id=ID_EDITINGPANELPARTLIST,
   357               name='PartList', parent=self, pos=wx.Point(0, 0),
   334               name='PartList', parent=self, pos=wx.Point(0, 0),
   358               size=wx.Size(-1, -1), style=0)
   335               size=wx.Size(-1, -1), style=0)
   359         self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick,
   336         self.PartList.Bind(wx.EVT_LISTBOX, self.OnPartListBoxClick,
   360               id=wxID_EDITINGPANELPARTLIST)
   337               id=ID_EDITINGPANELPARTLIST)
   361 
   338 
   362         self.SecondSplitter = wx.SplitterWindow(id=wxID_EDITINGPANELSECONDSPLITTER,
   339         self.SecondSplitter = wx.SplitterWindow(id=ID_EDITINGPANELSECONDSPLITTER,
   363               name='SecondSplitter', parent=self, point=wx.Point(0,
   340               name='SecondSplitter', parent=self, point=wx.Point(0, 0), 
   364               0), size=wx.Size(-1, -1), style=wx.SP_3D)
   341               size=wx.Size(-1, -1), style=wx.SP_3D)
   365         self.SecondSplitter.SetMinimumPaneSize(1)
   342         self.SecondSplitter.SetMinimumPaneSize(1)
   366         self.SplitHorizontally(self.PartList, self.SecondSplitter,
   343         self.SplitHorizontally(self.PartList, self.SecondSplitter,
   367               110)
   344               110)
   368 
   345 
   369         self.SubindexGridPanel = wx.Panel(id=wxID_EDITINGPANELSUBINDEXGRIDPANEL,
   346         self.SubindexGridPanel = wx.Panel(id=ID_EDITINGPANELSUBINDEXGRIDPANEL,
   370               name='SubindexGridPanel', parent=self.SecondSplitter, pos=wx.Point(0,
   347               name='SubindexGridPanel', parent=self.SecondSplitter, 
   371               0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
   348               pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
   372 
   349 
   373         self.IndexListPanel = wx.Panel(id=wxID_EDITINGPANELINDEXLISTPANEL,
   350         self.IndexListPanel = wx.Panel(id=ID_EDITINGPANELINDEXLISTPANEL,
   374               name='IndexListPanel', parent=self.SecondSplitter, pos=wx.Point(0,
   351               name='IndexListPanel', parent=self.SecondSplitter, 
   375               0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
   352               pos=wx.Point(0, 0), size=wx.Size(-1, -1), style=wx.TAB_TRAVERSAL)
   376         self.SecondSplitter.SplitVertically(self.IndexListPanel,
   353         self.SecondSplitter.SplitVertically(self.IndexListPanel,
   377               self.SubindexGridPanel, 280)
   354               self.SubindexGridPanel, 280)
   378 
   355 
   379         self.SubindexGrid = wx.grid.Grid(id=wxID_EDITINGPANELSUBINDEXGRID,
   356         self.SubindexGrid = wx.grid.Grid(id=ID_EDITINGPANELSUBINDEXGRID,
   380               name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0,
   357               name='SubindexGrid', parent=self.SubindexGridPanel, pos=wx.Point(0,
   381               0), size=wx.Size(-1, -1), style=0)
   358               0), size=wx.Size(-1, -1), style=0)
   382         self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
   359         self.SubindexGrid.SetFont(wx.Font(12, 77, wx.NORMAL, wx.NORMAL, False,
   383               'Sans'))
   360               'Sans'))
   384         self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
   361         self.SubindexGrid.SetLabelFont(wx.Font(10, 77, wx.NORMAL, wx.NORMAL,
   389               self.OnSubindexGridRightClick)
   366               self.OnSubindexGridRightClick)
   390         self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL,
   367         self.SubindexGrid.Bind(wx.grid.EVT_GRID_SELECT_CELL,
   391               self.OnSubindexGridSelectCell)
   368               self.OnSubindexGridSelectCell)
   392         self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick)
   369         self.SubindexGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnSubindexGridCellLeftClick)
   393 
   370 
   394         self.CallbackCheck = wx.CheckBox(id=wxID_EDITINGPANELCALLBACKCHECK,
   371         self.CallbackCheck = wx.CheckBox(id=ID_EDITINGPANELCALLBACKCHECK,
   395               label='Have Callbacks', name='CallbackCheck',
   372               label='Have Callbacks', name='CallbackCheck',
   396               parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152,
   373               parent=self.SubindexGridPanel, pos=wx.Point(0, 0), size=wx.Size(152,
   397               24), style=0)
   374               24), style=0)
   398         self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck,
   375         self.CallbackCheck.Bind(wx.EVT_CHECKBOX, self.OnCallbackCheck,
   399               id=wxID_EDITINGPANELCALLBACKCHECK)
   376               id=ID_EDITINGPANELCALLBACKCHECK)
   400 
   377 
   401         self.IndexList = wx.ListBox(choices=[], id=wxID_EDITINGPANELINDEXLIST,
   378         self.IndexList = wx.ListBox(choices=[], id=ID_EDITINGPANELINDEXLIST,
   402               name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0),
   379               name='IndexList', parent=self.IndexListPanel, pos=wx.Point(0, 0),
   403               size=wx.Size(-1, -1), style=0)
   380               size=wx.Size(-1, -1), style=0)
   404         self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick,
   381         self.IndexList.Bind(wx.EVT_LISTBOX, self.OnIndexListClick,
   405               id=wxID_EDITINGPANELINDEXLIST)
   382               id=ID_EDITINGPANELINDEXLIST)
   406         self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp)
   383         self.IndexList.Bind(wx.EVT_RIGHT_UP, self.OnIndexListRightUp)
   407 
   384 
   408         self.AddButton = wx.Button(id=wxID_EDITINGPANELADDBUTTON, label='Add',
   385         self.AddButton = wx.Button(id=ID_EDITINGPANELADDBUTTON, label='Add',
   409               name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0),
   386               name='AddButton', parent=self.IndexListPanel, pos=wx.Point(0, 0),
   410               size=wx.Size(50, 30), style=0)
   387               size=wx.Size(50, 30), style=0)
   411         self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick,
   388         self.AddButton.Bind(wx.EVT_BUTTON, self.OnAddButtonClick,
   412               id=wxID_EDITINGPANELADDBUTTON)
   389               id=ID_EDITINGPANELADDBUTTON)
   413 
   390 
   414         self.IndexChoice = wx.Choice(choices=[], id=wxID_EDITINGPANELINDEXCHOICE,
   391         self.IndexChoice = wx.Choice(choices=[], id=ID_EDITINGPANELINDEXCHOICE,
   415               name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50,
   392               name='IndexChoice', parent=self.IndexListPanel, pos=wx.Point(50,
   416               0), size=wx.Size(-1, 30), style=0)
   393               0), size=wx.Size(-1, 30), style=0)
   417 
   394 
   418         self._init_sizers()
   395         self._init_sizers()
   419 
   396 
   448     def SetIndex(self, index):
   425     def SetIndex(self, index):
   449         self.Index = index
   426         self.Index = index
   450 
   427 
   451     def GetSelection(self):
   428     def GetSelection(self):
   452         selected = self.IndexList.GetSelection()
   429         selected = self.IndexList.GetSelection()
   453         if selected != wxNOT_FOUND:
   430         if selected != wx.NOT_FOUND:
   454             index = self.ListIndex[selected]
   431             index = self.ListIndex[selected]
   455             subIndex = self.SubindexGrid.GetGridCursorRow()
   432             subIndex = self.SubindexGrid.GetGridCursorRow()
   456             return index, subIndex
   433             return index, subIndex
   457         return None
   434         return None
   458 
   435 
   459     def OnSubindexGridCellLeftClick(self, event):
   436     def OnSubindexGridCellLeftClick(self, event):
   460         wxCallAfter(self.BeginDrag)
   437         wx.CallAfter(self.BeginDrag)
   461         event.Skip()
   438         event.Skip()
   462 
   439 
   463     def OnAddButtonClick(self, event):
   440     def OnAddButtonClick(self, event):
   464         if self.Editable:
   441         if self.Editable:
   465             self.SubindexGrid.SetGridCursor(0, 0)
   442             self.SubindexGrid.SetGridCursor(0, 0)
   495         self.SubindexGrid.SetGridCursor(0, 0)
   472         self.SubindexGrid.SetGridCursor(0, 0)
   496         self.RefreshTable()
   473         self.RefreshTable()
   497         event.Skip()
   474         event.Skip()
   498 
   475 
   499     def OnSubindexGridSelectCell(self, event):
   476     def OnSubindexGridSelectCell(self, event):
   500         wxCallAfter(self.BeginDrag)
   477         wx.CallAfter(self.BeginDrag)
   501         wxCallAfter(self.Parent.RefreshStatusBar)
   478         wx.CallAfter(self.Parent.RefreshStatusBar)
   502         event.Skip()
   479         event.Skip()
   503 
   480 
   504     def BeginDrag(self):
   481     def BeginDrag(self):
   505         if not self.Parent.ModeSolo:
   482         if not self.Parent.ModeSolo:
   506             row = self.SubindexGrid.GetGridCursorRow()
   483             row = self.SubindexGrid.GetGridCursorRow()
   507             col = self.SubindexGrid.GetGridCursorCol()
   484             col = self.SubindexGrid.GetGridCursorCol()
   508             if not self.Editable and col == 0:
   485             if not self.Editable and col == 0:
   509                 selected = self.IndexList.GetSelection()
   486                 selected = self.IndexList.GetSelection()
   510                 if selected != wxNOT_FOUND:
   487                 if selected != wx.NOT_FOUND:
   511                     index = self.ListIndex[selected]
   488                     index = self.ListIndex[selected]
   512                     subindex = self.SubindexGrid.GetGridCursorRow()
   489                     subindex = self.SubindexGrid.GetGridCursorRow()
   513                     entry_infos = self.Manager.GetEntryInfos(index)
   490                     entry_infos = self.Manager.GetEntryInfos(index)
   514                     if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0:
   491                     if not entry_infos["struct"] & OD_MultipleSubindexes or row != 0:
   515                         subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
   492                         subentry_infos = self.Manager.GetSubentryInfos(index, subindex)
   516                         typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
   493                         typeinfos = self.Manager.GetEntryInfos(subentry_infos["type"])
   517                         if subentry_infos["pdo"] and typeinfos:
   494                         if subentry_infos["pdo"] and typeinfos:
   518                             bus_id = self.Parent.GetBusId()
   495                             bus_id = self.Parent.GetBusId()
   519                             node_id = self.Parent.GetCurrentNodeId()
   496                             node_id = self.Parent.GetCurrentNodeId()
   520                             size = typeinfos["size"]
   497                             size = typeinfos["size"]
   521                             data = wxTextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location")))
   498                             data = wx.TextDataObject(str(("%s%d.%d.%d.%d"%(SizeConversion[size], bus_id, node_id, index, subindex), "location")))
   522                             dragSource = wxDropSource(self.SubindexGrid)
   499                             dragSource = wx.DropSource(self.SubindexGrid)
   523                             dragSource.SetData(data)
   500                             dragSource.SetData(data)
   524                             dragSource.DoDragDrop()
   501                             dragSource.DoDragDrop()
   525 
   502 
   526 #-------------------------------------------------------------------------------
   503 #-------------------------------------------------------------------------------
   527 #                             Refresh Functions
   504 #                             Refresh Functions
   529 
   506 
   530     def RefreshIndexList(self):
   507     def RefreshIndexList(self):
   531         selected = self.IndexList.GetSelection()
   508         selected = self.IndexList.GetSelection()
   532         choice = self.IndexChoice.GetStringSelection()
   509         choice = self.IndexChoice.GetStringSelection()
   533         choiceindex = self.IndexChoice.GetSelection()
   510         choiceindex = self.IndexChoice.GetSelection()
   534         if selected != wxNOT_FOUND:
   511         if selected != wx.NOT_FOUND:
   535             selectedindex = self.ListIndex[selected]
   512             selectedindex = self.ListIndex[selected]
   536         self.IndexList.Clear()
   513         self.IndexList.Clear()
   537         self.IndexChoice.Clear()
   514         self.IndexChoice.Clear()
   538         i = self.PartList.GetSelection()
   515         i = self.PartList.GetSelection()
   539         if i < len(DictionaryOrganisation):
   516         if i < len(DictionaryOrganisation):
   548                     self.IndexChoice.Append("User Type")
   525                     self.IndexChoice.Append("User Type")
   549                     self.IndexChoice.SetStringSelection("User Type")
   526                     self.IndexChoice.SetStringSelection("User Type")
   550                 elif i == 2:
   527                 elif i == 2:
   551                     self.IndexChoice.Append("SDO Server")
   528                     self.IndexChoice.Append("SDO Server")
   552                     self.IndexChoice.Append("SDO Client")
   529                     self.IndexChoice.Append("SDO Client")
   553                     if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
   530                     if choiceindex != wx.NOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
   554                          self.IndexChoice.SetStringSelection(choice)
   531                          self.IndexChoice.SetStringSelection(choice)
   555                 elif i in (3, 4):
   532                 elif i in (3, 4):
   556                     self.IndexChoice.Append("PDO Receive")
   533                     self.IndexChoice.Append("PDO Receive")
   557                     self.IndexChoice.SetStringSelection("PDO Receive")
   534                     self.IndexChoice.SetStringSelection("PDO Receive")
   558                 elif i in (5, 6):
   535                 elif i in (5, 6):
   566                         if index:
   543                         if index:
   567                             self.IndexChoice.Append("0x%04X   %s"%(index, name))
   544                             self.IndexChoice.Append("0x%04X   %s"%(index, name))
   568                         else:
   545                         else:
   569                             self.IndexChoice.Append(name)
   546                             self.IndexChoice.Append(name)
   570                         self.ChoiceIndex.append(index)
   547                         self.ChoiceIndex.append(index)
   571                 if choiceindex != wxNOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
   548                 if choiceindex != wx.NOT_FOUND and choice == self.IndexChoice.GetString(choiceindex):
   572                     self.IndexChoice.SetStringSelection(choice)
   549                     self.IndexChoice.SetStringSelection(choice)
   573         if self.Editable:
   550         if self.Editable:
   574             self.IndexChoice.Enable(self.IndexChoice.GetCount() != 0)
   551             self.IndexChoice.Enable(self.IndexChoice.GetCount() != 0)
   575             self.AddButton.Enable(self.IndexChoice.GetCount() != 0)
   552             self.AddButton.Enable(self.IndexChoice.GetCount() != 0)
   576         if selected == wxNOT_FOUND or selected >= len(self.ListIndex) or selectedindex != self.ListIndex[selected]:
   553         if selected == wx.NOT_FOUND or selected >= len(self.ListIndex) or selectedindex != self.ListIndex[selected]:
   577             self.Table.Empty()
   554             self.Table.Empty()
   578             self.CallbackCheck.SetValue(False)
   555             self.CallbackCheck.SetValue(False)
   579             self.CallbackCheck.Disable()
   556             self.CallbackCheck.Disable()
   580             self.Table.ResetView(self.SubindexGrid)
   557             self.Table.ResetView(self.SubindexGrid)
   581             self.Parent.RefreshStatusBar()
   558             self.Parent.RefreshStatusBar()
   583             self.IndexList.SetSelection(selected)
   560             self.IndexList.SetSelection(selected)
   584             self.RefreshTable()
   561             self.RefreshTable()
   585 
   562 
   586     def RefreshTable(self):
   563     def RefreshTable(self):
   587         selected = self.IndexList.GetSelection()
   564         selected = self.IndexList.GetSelection()
   588         if selected != wxNOT_FOUND:
   565         if selected != wx.NOT_FOUND:
   589             index = self.ListIndex[selected]
   566             index = self.ListIndex[selected]
   590             if index > 0x260 and self.Editable:
   567             if index > 0x260 and self.Editable:
   591                 self.CallbackCheck.Enable()
   568                 self.CallbackCheck.Enable()
   592                 self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index))
   569                 self.CallbackCheck.SetValue(self.Manager.HasCurrentEntryCallbacks(index))
   593             result = self.Manager.GetCurrentEntryValues(index)
   570             result = self.Manager.GetCurrentEntryValues(index)
   611             name = self.Table.GetColLabelValue(col)
   588             name = self.Table.GetColLabelValue(col)
   612             value = self.Table.GetValue(subIndex, col)
   589             value = self.Table.GetValue(subIndex, col)
   613             editor = self.Table.GetEditor(subIndex, col)
   590             editor = self.Table.GetEditor(subIndex, col)
   614             self.Manager.SetCurrentEntry(index, subIndex, value, name, editor)
   591             self.Manager.SetCurrentEntry(index, subIndex, value, name, editor)
   615             self.Parent.RefreshBufferState()
   592             self.Parent.RefreshBufferState()
   616             wxCallAfter(self.RefreshTable)
   593             wx.CallAfter(self.RefreshTable)
   617         event.Skip()
   594         event.Skip()
   618 
   595 
   619     def OnCallbackCheck(self, event):
   596     def OnCallbackCheck(self, event):
   620         if self.Editable:
   597         if self.Editable:
   621             index = self.Table.GetCurrentIndex()
   598             index = self.Table.GetCurrentIndex()
   622             self.Manager.SetCurrentEntryCallbacks(index, self.CallbackCheck.GetValue())
   599             self.Manager.SetCurrentEntryCallbacks(index, self.CallbackCheck.GetValue())
   623             self.Parent.RefreshBufferState()
   600             self.Parent.RefreshBufferState()
   624             wxCallAfter(self.RefreshTable)
   601             wx.CallAfter(self.RefreshTable)
   625         event.Skip()
   602         event.Skip()
   626 
   603 
   627 #-------------------------------------------------------------------------------
   604 #-------------------------------------------------------------------------------
   628 #                          Contextual Menu functions
   605 #                          Contextual Menu functions
   629 #-------------------------------------------------------------------------------
   606 #-------------------------------------------------------------------------------
   631     def OnIndexListRightUp(self, event):
   608     def OnIndexListRightUp(self, event):
   632         if self.Editable:
   609         if self.Editable:
   633             if not self.FirstCall:
   610             if not self.FirstCall:
   634                 self.FirstCall = True
   611                 self.FirstCall = True
   635                 selected = self.IndexList.GetSelection()
   612                 selected = self.IndexList.GetSelection()
   636                 if selected != wxNOT_FOUND:
   613                 if selected != wx.NOT_FOUND:
   637                     index = self.ListIndex[selected]
   614                     index = self.ListIndex[selected]
   638                     if index < 0x260:
   615                     if index < 0x260:
   639                         self.IndexListMenu.FindItemByPosition(0).Enable(False)
   616                         self.IndexListMenu.FindItemByPosition(0).Enable(False)
   640                         self.IndexListMenu.FindItemByPosition(1).Enable(True)
   617                         self.IndexListMenu.FindItemByPosition(1).Enable(True)
   641                         self.PopupMenu(self.IndexListMenu)
   618                         self.PopupMenu(self.IndexListMenu)
   656         event.Skip()
   633         event.Skip()
   657 
   634 
   658     def OnSubindexGridRightClick(self, event):
   635     def OnSubindexGridRightClick(self, event):
   659         if self.Editable:
   636         if self.Editable:
   660             selected = self.IndexList.GetSelection()
   637             selected = self.IndexList.GetSelection()
   661             if selected != wxNOT_FOUND:
   638             if selected != wx.NOT_FOUND:
   662                 index = self.ListIndex[selected]
   639                 index = self.ListIndex[selected]
   663                 if self.Manager.IsCurrentEntry(index):
   640                 if self.Manager.IsCurrentEntry(index):
   664                     infos = self.Manager.GetEntryInfos(index)
   641                     infos = self.Manager.GetEntryInfos(index)
   665                     if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes:
   642                     if index >= 0x2000 and infos["struct"] & OD_MultipleSubindexes or infos["struct"] & OD_IdenticalSubindexes:
   666                         self.PopupMenu(self.SubindexGridMenu)
   643                         self.PopupMenu(self.SubindexGridMenu)
   667         event.Skip()
   644         event.Skip()
   668 
   645 
   669     def OnRenameIndexMenu(self, event):
   646     def OnRenameIndexMenu(self, event):
   670         if self.Editable:
   647         if self.Editable:
   671             selected = self.IndexList.GetSelection()
   648             selected = self.IndexList.GetSelection()
   672             if selected != wxNOT_FOUND:
   649             if selected != wx.NOT_FOUND:
   673                 index = self.ListIndex[selected]
   650                 index = self.ListIndex[selected]
   674                 if self.Manager.IsCurrentEntry(index):
   651                 if self.Manager.IsCurrentEntry(index):
   675                     infos = self.Manager.GetEntryInfos(index)
   652                     infos = self.Manager.GetEntryInfos(index)
   676                     dialog = wxTextEntryDialog(self, "Give a new name for index 0x%04X"%index,
   653                     dialog = wx.TextEntryDialog(self, "Give a new name for index 0x%04X"%index,
   677                                  "Rename an index", infos["name"], wxOK|wxCANCEL)
   654                                  "Rename an index", infos["name"], wx.OK|wx.CANCEL)
   678                     if dialog.ShowModal() == wxID_OK:
   655                     if dialog.ShowModal() == wx.ID_OK:
   679                         self.Manager.SetCurrentEntryName(index, dialog.GetValue())
   656                         self.Manager.SetCurrentEntryName(index, dialog.GetValue())
   680                         self.Parent.RefreshBufferState()
   657                         self.Parent.RefreshBufferState()
   681                         self.RefreshIndexList()
   658                         self.RefreshIndexList()
   682                     dialog.Destroy()
   659                     dialog.Destroy()
   683         event.Skip()
   660         event.Skip()
   684 
   661 
   685     def OnModifyIndexMenu(self, event):
   662     def OnModifyIndexMenu(self, event):
   686         if self.Editable:
   663         if self.Editable:
   687             selected = self.IndexList.GetSelection()
   664             selected = self.IndexList.GetSelection()
   688             if selected != wxNOT_FOUND:
   665             if selected != wx.NOT_FOUND:
   689                 index = self.ListIndex[selected]
   666                 index = self.ListIndex[selected]
   690                 if self.Manager.IsCurrentEntry(index) and index < 0x260:
   667                 if self.Manager.IsCurrentEntry(index) and index < 0x260:
   691                     values, valuetype = self.Manager.GetCustomisedTypeValues(index)
   668                     values, valuetype = self.Manager.GetCustomisedTypeValues(index)
   692                     dialog = UserTypeDialog(self)
   669                     dialog = UserTypeDialog(self)
   693                     dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1])
   670                     dialog.SetTypeList(self.Manager.GetCustomisableTypes(), values[1])
   694                     if valuetype == 0:
   671                     if valuetype == 0:
   695                         dialog.SetValues(min = values[2], max = values[3])
   672                         dialog.SetValues(min = values[2], max = values[3])
   696                     elif valuetype == 1:
   673                     elif valuetype == 1:
   697                         dialog.SetValues(length = values[2])
   674                         dialog.SetValues(length = values[2])
   698                     if dialog.ShowModal() == wxID_OK:
   675                     if dialog.ShowModal() == wx.ID_OK:
   699                         type, min, max, length = dialog.GetValues()
   676                         type, min, max, length = dialog.GetValues()
   700                         self.Manager.SetCurrentUserType(index, type, min, max, length)
   677                         self.Manager.SetCurrentUserType(index, type, min, max, length)
   701                         self.Parent.RefreshBufferState()
   678                         self.Parent.RefreshBufferState()
   702                         self.RefreshIndexList()
   679                         self.RefreshIndexList()
   703         event.Skip()
   680         event.Skip()
   704         
   681         
   705     def OnDeleteIndexMenu(self, event):
   682     def OnDeleteIndexMenu(self, event):
   706         if self.Editable:
   683         if self.Editable:
   707             selected = self.IndexList.GetSelection()
   684             selected = self.IndexList.GetSelection()
   708             if selected != wxNOT_FOUND:
   685             if selected != wx.NOT_FOUND:
   709                 index = self.ListIndex[selected]
   686                 index = self.ListIndex[selected]
   710                 if self.Manager.IsCurrentEntry(index):
   687                 if self.Manager.IsCurrentEntry(index):
   711                     self.Manager.ManageEntriesOfCurrent([],[index])
   688                     self.Manager.ManageEntriesOfCurrent([],[index])
   712                     self.Parent.RefreshBufferState()
   689                     self.Parent.RefreshBufferState()
   713                     self.RefreshIndexList()
   690                     self.RefreshIndexList()
   714         event.Skip()
   691         event.Skip()
   715 
   692 
   716     def OnAddSubindexMenu(self, event):
   693     def OnAddSubindexMenu(self, event):
   717         if self.Editable:
   694         if self.Editable:
   718             selected = self.IndexList.GetSelection()
   695             selected = self.IndexList.GetSelection()
   719             if selected != wxNOT_FOUND:
   696             if selected != wx.NOT_FOUND:
   720                 index = self.ListIndex[selected]
   697                 index = self.ListIndex[selected]
   721                 if self.Manager.IsCurrentEntry(index):
   698                 if self.Manager.IsCurrentEntry(index):
   722                     dialog = wxTextEntryDialog(self, "Number of subindexes to add:",
   699                     dialog = wx.TextEntryDialog(self, "Number of subindexes to add:",
   723                                  "Add subindexes", "1", wxOK|wxCANCEL)
   700                                  "Add subindexes", "1", wx.OK|wx.CANCEL)
   724                     if dialog.ShowModal() == wxID_OK:
   701                     if dialog.ShowModal() == wx.ID_OK:
   725                         try:
   702                         try:
   726                             number = int(dialog.GetValue())
   703                             number = int(dialog.GetValue())
   727                             self.Manager.AddSubentriesToCurrent(index, number)
   704                             self.Manager.AddSubentriesToCurrent(index, number)
   728                             self.Parent.RefreshBufferState()
   705                             self.Parent.RefreshBufferState()
   729                             self.RefreshIndexList()
   706                             self.RefreshIndexList()
   730                         except:
   707                         except:
   731                             message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
   708                             message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR)
   732                             message.ShowModal()
   709                             message.ShowModal()
   733                             message.Destroy()
   710                             message.Destroy()
   734                     dialog.Destroy()
   711                     dialog.Destroy()
   735         event.Skip()
   712         event.Skip()
   736 
   713 
   737     def OnDeleteSubindexMenu(self, event):
   714     def OnDeleteSubindexMenu(self, event):
   738         if self.Editable:
   715         if self.Editable:
   739             selected = self.IndexList.GetSelection()
   716             selected = self.IndexList.GetSelection()
   740             if selected != wxNOT_FOUND:
   717             if selected != wx.NOT_FOUND:
   741                 index = self.ListIndex[selected]
   718                 index = self.ListIndex[selected]
   742                 if self.Manager.IsCurrentEntry(index):
   719                 if self.Manager.IsCurrentEntry(index):
   743                     dialog = wxTextEntryDialog(self, "Number of subindexes to delete:",
   720                     dialog = wx.TextEntryDialog(self, "Number of subindexes to delete:",
   744                                  "Delete subindexes", "1", wxOK|wxCANCEL)
   721                                  "Delete subindexes", "1", wx.OK|wx.CANCEL)
   745                     if dialog.ShowModal() == wxID_OK:
   722                     if dialog.ShowModal() == wx.ID_OK:
   746                         try:
   723                         try:
   747                             number = int(dialog.GetValue())
   724                             number = int(dialog.GetValue())
   748                             self.Manager.RemoveSubentriesFromCurrent(index, number)
   725                             self.Manager.RemoveSubentriesFromCurrent(index, number)
   749                             self.Parent.RefreshBufferState()
   726                             self.Parent.RefreshBufferState()
   750                             self.RefreshIndexList()
   727                             self.RefreshIndexList()
   751                         except:
   728                         except:
   752                             message = wxMessageDialog(self, "An integer is required!", "ERROR", wxOK|wxICON_ERROR)
   729                             message = wx.MessageDialog(self, "An integer is required!", "ERROR", wx.OK|wx.ICON_ERROR)
   753                             message.ShowModal()
   730                             message.ShowModal()
   754                             message.Destroy()
   731                             message.Destroy()
   755                     dialog.Destroy()
   732                     dialog.Destroy()
   756         event.Skip()
   733         event.Skip()
   757 
   734