How to override PyGridTableBase.SetColLabelValue()?

ajaksu ajaksu at
Mon Jul 9 06:42:25 CEST 2007

On Jul 9, 12:27 am, fck... at wrote:
> Dear all,
> the doc is missing, and i failed to find the solution on google search.
> anyone know how to override the function SetColLabel() inside
> the class PyGridTableBase or the class GridTableBase?

Some docs to back up the old code that follows :)

I hope this helps, it's old and 2.6, the design had many weird
requirements plus I never got to think about whether it was a good way
to do it. Anyway, the docs are far better :)

> my code,
class SpeciesBase(object):
    def __init__(self, ncols=1, nrows=15, colnames=None,
        self.__data = []
        self.rows = []
        self.cols = []
    def __getitem__(self, col):
        return self.__data[col][:]

class SpeciesTableBase(wx.grid.PyGridTableBase):
    def __init__(self):
        wx.grid.PyGridTableBase.__init__(self) = SpeciesBase()
        self._rows = self.GetNumberRows()
        self._cols = self.GetNumberCols()
    def SetColLabelValue(self, col, value):[col] = str(value)
    def GetNumberRows(self):
        return len([0])

class SpeciesGrid(wx.grid.Grid):
    def __init__(self, parent):
        wx.grid.Grid.__init__(self, parent, -1)
        self.table = SpeciesTableBase()
    def rename_col(self, col, value):
        self.table.SetColLabelValue(col, value)

Other useful links:

More information about the Python-list mailing list