So far I've copied the grid examples from the demo where the cell renderer is set for individual cells. Since I actually have one type of cell, I loop over all of them setting it. It is however annoying when I try to add new rows, because I have to go again setting their cell renderer.
So I figured I could use SetDefaultRenderer. But it doesn't seem to work. Why? I have even moved it to the top of my Grid.__init__ method, just in case I have to set it before adding any data. Still see the normal rendering.
···
--
Grzegorz Adam Hankiewicz, Jefe de producto de TeraVial
Rastertech España S.A. Tel: +34 918 467 390, ext 18. http://www.rastertech.es/ ghankiewicz@rastertech.es
So far I've copied the grid examples from the demo where the cell
renderer is set for individual cells. Since I actually have one type of
cell, I loop over all of them setting it. It is however annoying when I
try to add new rows, because I have to go again setting their cell renderer.
If you are using a custom TableBase you can override its GetAttr method and and
let it return a GridCellAttr with a renderer of your choice, e.g.:
So I figured I could use SetDefaultRenderer. But it doesn't seem to
work. Why? I have even moved it to the top of my Grid.__init__ method,
just in case I have to set it before adding any data. Still see the
normal rendering.
I have not tried it but according to what the the docs say I would expect it
to work.
Can you send your code?
So far I've copied the grid examples from the demo where the cell renderer is set for individual cells. Since I actually have one
type of cell, I loop over all of them setting it. It is however
annoying when I try to add new rows, because I have to go again
setting their cell renderer.
If you are using a custom TableBase you can override its GetAttr
method and and let it return a GridCellAttr with a renderer of your
choice, e.g.:
I have not tried it but according to what the the docs say I would
expect it to work. Can you send your code?
Here it is. If you uncomment the lines which set the renderer explicitly
it will work as expected. I'm using 2.8.0.1 under MSW. I wonder if the memory leak fixed in 2.8.1.0 (patch 1629949) makes SetDefaultRenderer() work.
--
Grzegorz Adam Hankiewicz, Jefe de producto de TeraVial
Rastertech España S.A. Tel: +34 918 467 390, ext 18. http://www.rastertech.es/ ghankiewicz@rastertech.es
Grzegorz Adam Hankiewicz <ghankiewicz <at> rastertech.es> writes:
> I have not tried it but according to what the the docs say I would
> expect it to work. Can you send your code?
Here it is. If you uncomment the lines which set the renderer explicitly
it will work as expected. I'm using 2.8.0.1 under MSW. I wonder if the
memory leak fixed in 2.8.1.0 (patch 1629949) makes SetDefaultRenderer()
work.
Does not work here (linux, wxPython 2.8.1.0 and 2.6.3.3) either.
So far I've copied the grid examples from the demo where the cell renderer is set for individual cells. Since I actually have one
type of cell, I loop over all of them setting it. It is however
annoying when I try to add new rows, because I have to go again
setting their cell renderer.
If you are using a custom TableBase you can override its GetAttr
method and and let it return a GridCellAttr with a renderer of your
choice, e.g.:
I have not tried it but according to what the the docs say I would
expect it to work. Can you send your code?
Here it is. If you uncomment the lines which set the renderer explicitly
it will work as expected. I'm using 2.8.0.1 under MSW. I wonder if the memory leak fixed in 2.8.1.0 (patch 1629949) makes SetDefaultRenderer() work.
There is a precedence order in place for how to get the attributes, editor, renderer, etc. for a cell. There is also a data type registry for providing the editor and renderer based on the data type of the cell. Since the type registry has a higher precedence than the default cell attr then it's not really possible for the editor/renderer set in the default cell attribute to have any effect. So to compensate for this the SetDefaultRenderer and SetDefaultEditor functions were changed a few years ago to instead register a new editor/renderer for the default cell data type (string) instead of putting it into the default cell attr.
However in your example your table is telling the grid that every cell is a float type, so that registration of your default renderer for strings is not being used. Instead it is using the default registration for floats. So you can just override that instead of using SetDefaultCellRenderer: