About customizing GridCellFloatRenderer

hello everybody, I would like to make a little customization of the
GridCellFloatRenderer: drawing a little mark in a corner depending on
the value of the cell. To avoid re-implementing the renderer myself
(managing locale formatting, precision and so on), I've thought it
would be convenient to subclass GridCellFloatRenderer

class MpsCellRenderer(gridlib.GridCellFloatRenderer):
    def __init__(self):
        gridlib.GridCellFloatRenderer.__init__
(self,precision=3)
    def Draw(self, grid, attr, dc, rect, row, col,
isSelected):
        gridlib.GridCellFloatRenderer.Draw(self, grid, attr, dc, rect,
row, col, isSelected)
        print 'now draw in the cell corner'

but it looks as if my customized Draw method is never been called (the
GridCellFloatRenderer default one is used instead). Where am I going
wrong?

thanks, Marco

Marco Prosperi wrote:

hello everybody, I would like to make a little customization of the
GridCellFloatRenderer: drawing a little mark in a corner depending on
the value of the cell. To avoid re-implementing the renderer myself
(managing locale formatting, precision and so on), I've thought it
would be convenient to subclass GridCellFloatRenderer

class MpsCellRenderer(gridlib.GridCellFloatRenderer):
    def __init__(self):
        gridlib.GridCellFloatRenderer.__init__
(self,precision=3)
    def Draw(self, grid, attr, dc, rect, row, col,
isSelected):
        gridlib.GridCellFloatRenderer.Draw(self, grid, attr, dc, rect,
row, col, isSelected)
        print 'now draw in the cell corner'

but it looks as if my customized Draw method is never been called (the
GridCellFloatRenderer default one is used instead). Where am I going
wrong?

See OverridingMethods - wxPyWiki

You'll need to implement a whole new renderer class derived from PyGridCellRenderer.

···

--
Robin Dunn
Software Craftsman