def __init__(self, obsCombo, envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'obstacle' self.colLabels = ['Name', 'Definition', 'Category', 'Originator'] self.om = ObstacleManager(obsCombo, envCombo) self.obsName = obsCombo.GetValue() self.envName = envCombo.GetValue()
def __init__(self,obsCombo,envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'obstacle' self.colLabels = ['Name','Definition','Category','Originator'] self.om = ObstacleManager(obsCombo,envCombo) self.obsName = obsCombo.GetValue() self.envName = envCombo.GetValue()
class ObstaclesTable(wx.grid.PyGridTableBase): def __init__(self,obsCombo,envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'obstacle' self.colLabels = ['Name','Definition','Category','Originator'] self.om = ObstacleManager(obsCombo,envCombo) self.obsName = obsCombo.GetValue() self.envName = envCombo.GetValue() def object(self): return self.obsName def GetNumberRows(self): return self.om.size() def GetNumberCols(self): return len(self.colLabels) def GetColLabelValue(self,col): return self.colLabels[col] def GetRowLabelValue(self,row): return self.om.obstacles[row].label(self.envName) def IsEmptyCell(self,row,col): return False def GetValue(self,row,col): if (col == NAME_POS): return self.om.obstacles[row].name() elif (col == DEFINITION_POS): return self.om.obstacles[row].definition(self.envName) elif (col == CATEGORY_POS): return self.om.obstacles[row].category(self.envName) elif (col == ORIGINATOR_POS): return self.om.obstacles[row].originator() def SetValue(self,row,col,value): if (col == NAME_POS): self.om.obstacles[row].setName(value) elif (col == DEFINITION_POS): self.om.obstacles[row].setDefinition(self.envName,value) elif (col == CATEGORY_POS): self.om.obstacles[row].setCategory(self.envName,value) elif (col == ORIGINATOR_POS): self.om.obstacles[row].setOriginator(value) def AppendRows(self,numRows=1): pos = self.om.size() - 1 self.InsertRows(pos,numRows) def InsertRows(self,pos,numRows=1): onDlg = wx.TextEntryDialog(None,'Enter obstacle name','New Obstacle','',style=wx.OK|wx.CANCEL) if (onDlg.ShowModal() == wx.ID_OK): obsName = onDlg.GetValue() if (obsName != ''): if (pos == -1): pos = 0 newPos = pos + 1 try: self.om.add(newPos,obsName) except ARMException,errorText: dlg = wx.MessageDialog(self.GetView(),str(errorText),'Add Obstacle',wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return self.addToView(newPos) grid = self.GetView() grid.SetCellEditor(newPos,NAME_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,NAME_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,DEFINITION_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,DEFINITION_POS,wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos,CATEGORY_POS,wx.grid.GridCellChoiceEditor(catChoices)) grid.SetCellEditor(newPos,ORIGINATOR_POS,wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos,ORIGINATOR_POS,wx.grid.GridCellAutoWrapStringRenderer()) onDlg.Destroy() return True
class ObstaclesTable(wx.grid.PyGridTableBase): def __init__(self, obsCombo, envCombo): wx.grid.PyGridTableBase.__init__(self) self.dimension = 'obstacle' self.colLabels = ['Name', 'Definition', 'Category', 'Originator'] self.om = ObstacleManager(obsCombo, envCombo) self.obsName = obsCombo.GetValue() self.envName = envCombo.GetValue() def object(self): return self.obsName def GetNumberRows(self): return self.om.size() def GetNumberCols(self): return len(self.colLabels) def GetColLabelValue(self, col): return self.colLabels[col] def GetRowLabelValue(self, row): return self.om.obstacles[row].label(self.envName) def IsEmptyCell(self, row, col): return False def GetValue(self, row, col): if (col == NAME_POS): return self.om.obstacles[row].name() elif (col == DEFINITION_POS): return self.om.obstacles[row].definition(self.envName) elif (col == CATEGORY_POS): return self.om.obstacles[row].category(self.envName) elif (col == ORIGINATOR_POS): return self.om.obstacles[row].originator() def SetValue(self, row, col, value): if (col == NAME_POS): self.om.obstacles[row].setName(value) elif (col == DEFINITION_POS): self.om.obstacles[row].setDefinition(self.envName, value) elif (col == CATEGORY_POS): self.om.obstacles[row].setCategory(self.envName, value) elif (col == ORIGINATOR_POS): self.om.obstacles[row].setOriginator(value) def AppendRows(self, numRows=1): pos = self.om.size() - 1 self.InsertRows(pos, numRows) def InsertRows(self, pos, numRows=1): onDlg = wx.TextEntryDialog(None, 'Enter obstacle name', 'New Obstacle', '', style=wx.OK | wx.CANCEL) if (onDlg.ShowModal() == wx.ID_OK): obsName = onDlg.GetValue() if (obsName != ''): if (pos == -1): pos = 0 newPos = pos + 1 try: self.om.add(newPos, obsName) except ARMException, errorText: dlg = wx.MessageDialog(self.GetView(), str(errorText), 'Add Obstacle', wx.OK | wx.ICON_ERROR) dlg.ShowModal() dlg.Destroy() return self.addToView(newPos) grid = self.GetView() grid.SetCellEditor(newPos, NAME_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, NAME_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, DEFINITION_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, DEFINITION_POS, wx.grid.GridCellAutoWrapStringRenderer()) grid.SetCellEditor(newPos, CATEGORY_POS, wx.grid.GridCellChoiceEditor(catChoices)) grid.SetCellEditor(newPos, ORIGINATOR_POS, wx.grid.GridCellAutoWrapStringEditor()) grid.SetCellRenderer(newPos, ORIGINATOR_POS, wx.grid.GridCellAutoWrapStringRenderer()) onDlg.Destroy() return True