How to override PyGridTableBase.SetColLabelValue()?

Frank Millman frank at chagford.com
Mon Jul 9 00:53:17 EDT 2007


On Jul 9, 5:27 am, fck... at gmail.com 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?
>
> my code,
> #===========================================
> class MegaTable(wx.grid.PyGridTableBase):
> def __init__(...)
> .....
> wx.grid.PyGridTableBase.__init__(self)
>
> def SetColLabelValue(self, col, value):
> value = self.coltags[col]
> -->how to ???
>
> class MegaGrid(wx.grid.Grid):
> def __init__(...)
> .....
> wx.grid.Grid.__init__(self, parent, id)
> self._table = MegaTable(self, .....)
> self.SetTable(self._table)
> .....
> #===========================================
>
> thanks!

You are not supposed to override SetColLabel(), you are supposed to
override GetColLabelValue().

When you use PyGridTableBase, there could potentially be thousands of
columns, and wxPython does not want to keep track of thousands of
column labels.

Therefore, when wxPython needs to display a column label, it calls
GetColLabelValue(self,col). It is up to you to return the value to use
for that column.

HTH

Frank Millman




More information about the Python-list mailing list