Class providing attributes to be used for the grid cells.
This class both defines an interface which grid cell attributes providers should implement – and which can be implemented differently in derived classes – and a default implementation of this interface which is often good enough to be used without modification, especially with not very large grids for which the efficiency of attributes storage hardly matters (see the discussion below).
An object of this class can be associated with a wx.grid.Grid using wx.grid.GridTableBase.SetAttrProvider
but it’s not necessary to call it if you intend to use the default provider as it is used by wx.grid.GridTableBase by default anyhow.
Notice that while attributes provided by this class can be set for individual cells using SetAttr
or the entire rows or columns using SetRowAttr
and SetColAttr
they are always retrieved using GetAttr
function.
The default implementation of this class stores the attributes passed to its SetAttr
, SetRowAttr
and SetColAttr
in a straightforward way. A derived class may use its knowledge about how the attributes are used in your program to implement it much more efficiently: for example, using a special background colour for all even-numbered rows can be implemented by simply returning the same attribute from GetAttr
if the row number is even instead of having to store N/2 row attributes where N is the total number of rows in the grid.
Notice that objects of this class can’t be copied.
Trivial default constructor. |
|
Get the attribute to use for the specified cell. |
|
Get the attribute to use for the specified cell. |
|
Return the renderer used for drawing column headers. |
|
Return the renderer used for drawing the corner window. |
|
Return the renderer used for drawing row headers. |
|
Set attribute for the specified cell. |
|
Set attribute for the specified column. |
|
Set attribute for the specified row. |
wx.grid.
GridCellAttrProvider
(ClientDataContainer)¶Possible constructors:
GridCellAttrProvider()
Class providing attributes to be used for the grid cells.
__init__
(self)¶Trivial default constructor.
GetAttr
(self, row, col, kind)¶Get the attribute to use for the specified cell.
If wx.grid.GridCellAttr.Any
is used as kind value, this function combines the attributes set for this cell using SetAttr
and those for its row or column (set with SetRowAttr
or SetColAttr
respectively), with the cell attribute having the highest precedence.
Notice that the caller must call DecRef() on the returned pointer if it is not None
. GetAttrPtr
method can be used to do this automatically.
row (int) – The row of the cell.
col (int) – The column of the cell.
kind (GridCellAttr.wxAttrKind) – The kind of the attribute to return.
The attribute to use which should be DecRef()’d by caller or None
if no attributes are defined for this cell.
GetAttrPtr
(self, row, col, kind)¶Get the attribute to use for the specified cell.
This method is identical to GetAttr
, but returns a smart pointer, which frees the caller from the need to call DecRef() manually.
row (int) –
col (int) –
kind (GridCellAttr.wxAttrKind) –
wx.grid.GridCellAttrPtr
New in version 4.1/wxWidgets-3.1.4.
GetColumnHeaderRenderer
(self, col)¶Return the renderer used for drawing column headers.
By default wx.grid.GridColumnHeaderRendererDefault is returned.
col (int) –
New in version 2.9.1.
GetCornerRenderer
(self)¶Return the renderer used for drawing the corner window.
By default wx.grid.GridCornerHeaderRendererDefault is returned.
New in version 2.9.1.
GetRowHeaderRenderer
(self, row)¶Return the renderer used for drawing row headers.
By default wx.grid.GridRowHeaderRendererDefault is returned.
row (int) –
New in version 2.9.1.
SetAttr
(self, attr, row, col)¶Set attribute for the specified cell.
attr (wx.grid.GridCellAttr) –
row (int) –
col (int) –
SetColAttr
(self, attr, col)¶Set attribute for the specified column.
attr (wx.grid.GridCellAttr) –
col (int) –
SetRowAttr
(self, attr, row)¶Set attribute for the specified row.
attr (wx.grid.GridCellAttr) –
row (int) –
CornerRenderer
¶