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?
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.
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.