Grid and Grid table attributes

I have a grid connected to a grid table. Some of the cells need special renderers and editors, so I have a GetAttr() method in my table code to return the custom attribute.

The question is what do I return if no custom attribute is needed? Should I have a default attribute available to return in this case?

def GetAttr(self, row, col, kind):

if <–I need a custom attr here–>:

attr = mycustomattr

attr.IncRef()

return attr

Second question, what is the purpose of “kind” parameter to GetAttr()? Is it ever useful in my code?

···


Mike Conley

I have a grid connected to a grid table. Some of the cells need special
renderers and editors, so I have a GetAttr() method in my table code to
return the custom attribute.

The question is what do I return if no custom attribute is needed?
Should I have a default attribute available to return in this case?

Yes, that will work. I think you can also just return None.

Second question, what is the purpose of "kind" parameter to GetAttr()?
Is it ever useful in my code?

It is meant to be able to distinguish what kind of attribute is being asked for, cell, row, or column. I'm not sure if it was ever fully implemented however.

···

On 10/22/09 12:55 PM, Mike Conley wrote:

--
Robin Dunn
Software Craftsman

I looked at the C++ code and it does look like None should work

···

On Fri, Oct 23, 2009 at 4:00 AM, Robin Dunn robin@alldunn.com wrote:

On 10/22/09 12:55 PM, Mike Conley wrote:

I have a grid connected to a grid table. Some of the cells need special

renderers and editors, so I have a GetAttr() method in my table code to

return the custom attribute.

The question is what do I return if no custom attribute is needed?

Should I have a default attribute available to return in this case?

Yes, that will work. I think you can also just return None.

Seems there is one thing to be aware of though. If you return None, the grid will call GetAttr() multiple times for each cell whenever anything happens to the display of the grid causing any part of the grid to repaint. This could really destroy performance in a grid of any size. Better to have a default attribute ready to return. See attached example. Run with ‘Y’ as command line argument to return default attribute, anything else will return None. You can see that GetAttr() is called many times when None is returned.

gridtable1.py (1.96 KB)

···

On Fri, Oct 23, 2009 at 11:09 AM, Mike Conley mconley0@gmail.com wrote:

On Fri, Oct 23, 2009 at 4:00 AM, Robin Dunn robin@alldunn.com wrote:

On 10/22/09 12:55 PM, Mike Conley wrote:

I have a grid connected to a grid table. Some of the cells need special

renderers and editors, so I have a GetAttr() method in my table code to

return the custom attribute.

The question is what do I return if no custom attribute is needed?

Should I have a default attribute available to return in this case?

Yes, that will work. I think you can also just return None.

I looked at the C++ code and it does look like None should work