wx.grid.GridCellAttr¶
This class can be used to alter the cells’ appearance in the grid by changing their attributes from the defaults.
An object of this class may be returned by wx.grid.GridTableBase.GetAttr
.
Note that objects of this class are reference-counted and it’s recommended to use GridCellAttrPtr smart pointer class when working with them to avoid memory leaks.
Class Hierarchy¶
Methods Summary¶
Default constructor. |
|
Returns |
|
Creates a new copy of this object. |
|
This class is reference counted: it is created with ref count of 1, so calling |
|
Get the alignment to use for the cell with the given attribute. |
|
Returns the background colour. |
|
Returns the cell editor. |
|
Returns the cell editor. |
|
Returns the fitting mode for the cells using this attribute. |
|
Returns the font. |
|
Get the alignment defined by this attribute. |
|
Returns |
|
Returns the cell renderer. |
|
Returns the text colour. |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
Returns |
|
This class is reference counted: it is created with ref count of 1, so calling |
|
Returns |
|
Sets the alignment. |
|
Sets the background colour. |
|
Sets the editor to be used with the cells with this attribute. |
|
Specifies the behaviour of the cell contents if it doesn’t fit into the available space. |
|
Sets the font. |
|
Specifies if cells using this attribute should overflow or clip their contents. |
|
Sets the cell as read-only. |
|
Sets the renderer to be used for cells with this attribute. |
|
Sets the text colour. |
|
|
The destructor is private because only |
Properties Summary¶
See |
|
See |
|
See |
Class API¶
- class wx.grid.GridCellAttr(SharedClientDataContainer, RefCounter)¶
Possible constructors:
GridCellAttr(attrDefault=None) -> None GridCellAttr(colText, colBack, font, hAlign, vAlign) -> None
This class can be used to alter the cells’ appearance in the grid by changing their attributes from the defaults.
Methods¶
- __init__(self, *args, **kw)¶
-
__init__ (self, attrDefault=None)
Default constructor.
- Parameters:
attrDefault (wx.grid.GridCellAttr)
- Return type:
None
__init__ (self, colText, colBack, font, hAlign, vAlign)
Constructor specifying some of the often used attributes.
- Parameters:
- Return type:
None
- CanOverflow(self)¶
Returns
True
if the cell will draw an overflowed text into the neighbouring cells.Note that only left aligned cells currently can overflow. It means that
GetFitMode
.IsOverflow() should returnsTrue
and GetAlignment should returnswx.ALIGN_LEFT
for hAlign parameter.- Return type:
bool
Added in version 4.1/wxWidgets-3.1.4.
- Clone(self)¶
Creates a new copy of this object.
- Return type:
- DecRef(self)¶
This class is reference counted: it is created with ref count of 1, so calling
DecRef
once will delete it.Calling
IncRef
allows locking it until the matchingDecRef
is called.- Return type:
None
- GetAlignment(self)¶
Get the alignment to use for the cell with the given attribute.
If this attribute doesn’t specify any alignment, the default attribute alignment is used (which can be changed using
wx.grid.Grid.SetDefaultCellAlignment
but is left and top by default).Notice that hAlign and vAlign values are always overwritten by this function, use
GetNonDefaultAlignment
if this is not desirable.- Return type:
Tuple[int, int]
- GetBackgroundColour(self)¶
Returns the background colour.
- Return type:
Colour
- GetEditor(self, grid, row, col)¶
Returns the cell editor.
The caller is responsible for calling
DecRef
on the returned pointer, useGetEditorPtr
to do it automatically.- Parameters:
grid (wx.grid.Grid)
row (int)
col (int)
- Return type:
- GetEditorPtr(self, grid, row, col)¶
Returns the cell editor.
This method is identical to
GetEditor
, but returns a smart pointer, which frees the caller from the need to callDecRef
manually.- Parameters:
grid (wx.grid.Grid)
row (int)
col (int)
- Return type:
wx.grid.GridCellEditorPtr
Added in version 4.1/wxWidgets-3.1.4.
- GetFitMode(self)¶
Returns the fitting mode for the cells using this attribute.
The returned wx.grid.GridFitMode is always specified, i.e.
wx.grid.GridFitMode.IsSpecified
always returnsTrue
. The default value, ifSetFitMode
hadn’t been called before, is “overflow”.- Return type:
Added in version 4.1/wxWidgets-3.1.4.
- GetKind(self)¶
- Return type:
- GetNonDefaultAlignment(self)¶
Get the alignment defined by this attribute.
Unlike
GetAlignment
this function only modifies hAlign and vAlign if this attribute does define a non-default alignment. This means that they must be initialized before calling this function and that their values will be preserved unchanged if they are different fromwx.ALIGN_INVALID
.For example, the following fragment can be used to use the cell alignment if one is defined but right-align its contents by default (instead of left-aligning it by default) while still using the default vertical alignment:
hAlign = wx.ALIGN_RIGHT vAlign = wx.ALIGN_INVALID hAlign, vAlign = attr.GetNonDefaultAlignment()
- Return type:
Tuple[int, int]
Added in version 2.9.1.
- GetOverflow(self)¶
Returns
True
if the cells using this attribute overflow into the neighbouring cells.Prefer using
GetFitMode
in the new code.- Return type:
bool
- GetRenderer(self, grid, row, col)¶
Returns the cell renderer.
The caller is responsible for calling
DecRef
on the returned pointer, useGetRendererPtr
to do it automatically.- Parameters:
grid (wx.grid.Grid)
row (int)
col (int)
- Return type:
- GetSize(self)¶
- Return type:
Tuple[int, int]
- GetTextColour(self)¶
Returns the text colour.
- Return type:
Colour
- HasAlignment(self)¶
Returns
True
if this attribute has a valid alignment set.- Return type:
bool
- HasBackgroundColour(self)¶
Returns
True
if this attribute has a valid background colour set.- Return type:
bool
- HasEditor(self)¶
Returns
True
if this attribute has a valid cell editor set.- Return type:
bool
- HasFont(self)¶
Returns
True
if this attribute has a valid font set.- Return type:
bool
- HasOverflowMode(self)¶
- Return type:
bool
- HasReadWriteMode(self)¶
- Return type:
bool
- HasRenderer(self)¶
Returns
True
if this attribute has a valid cell renderer set.- Return type:
bool
- HasSize(self)¶
- Return type:
bool
- HasTextColour(self)¶
Returns
True
if this attribute has a valid text colour set.- Return type:
bool
- IncRef(self)¶
This class is reference counted: it is created with ref count of 1, so calling
DecRef
once will delete it.Calling
IncRef
allows locking it until the matchingDecRef
is called.- Return type:
None
- IsReadOnly(self)¶
Returns
True
if this cell is set as read-only.- Return type:
bool
- MergeWith(self, mergefrom)¶
- Parameters:
mergefrom (wx.grid.GridCellAttr)
- Return type:
None
- SetAlignment(self, hAlign, vAlign)¶
Sets the alignment.
hAlign can be one of
ALIGN_LEFT
,ALIGN_CENTRE
orALIGN_RIGHT
and vAlign can be one ofALIGN_TOP
,ALIGN_CENTRE
orALIGN_BOTTOM
.- Parameters:
hAlign (int)
vAlign (int)
- Return type:
None
- SetBackgroundColour(self, colBack)¶
Sets the background colour.
- Parameters:
colBack (wx.Colour)
- Return type:
None
- SetDefAttr(self, defAttr)¶
- Parameters:
defAttr (wx.grid.GridCellAttr)
- Return type:
None
Todo
Needs documentation.
- SetEditor(self, editor)¶
Sets the editor to be used with the cells with this attribute.
- Parameters:
editor (wx.grid.GridCellEditor)
- Return type:
None
- SetFitMode(self, fitMode)¶
Specifies the behaviour of the cell contents if it doesn’t fit into the available space.
- Parameters:
fitMode (wx.grid.GridFitMode)
- Return type:
None
Added in version 4.1/wxWidgets-3.1.4.
See also
- SetOverflow(self, allow=True)¶
Specifies if cells using this attribute should overflow or clip their contents.
This is the same as calling
SetFitMode
with eitherwx.grid.GridFitMode.Overflow
orwx.grid.GridFitMode.Clip
argument depending on whether allow isTrue
orFalse
.Prefer using
SetFitMode
directly instead in the new code.- Parameters:
allow (bool)
- Return type:
None
- SetReadOnly(self, isReadOnly=True)¶
Sets the cell as read-only.
- Parameters:
isReadOnly (bool)
- Return type:
None
- SetRenderer(self, renderer)¶
Sets the renderer to be used for cells with this attribute.
Takes ownership of the pointer.
- Parameters:
renderer (wx.grid.GridCellRenderer)
- Return type:
None
- SetSize(self, num_rows, num_cols)¶
- Parameters:
num_rows (int)
num_cols (int)
- Return type:
None
- SetTextColour(self, colText)¶
Sets the text colour.
- Parameters:
colText (wx.Colour)
- Return type:
None
- ~wxGridCellAttr(self)
The destructor is private because only
DecRef
can delete us.- Return type:
None
Properties¶
- BackgroundColour¶
- FitMode¶
See
GetFitMode
andSetFitMode
- Overflow¶
See
GetOverflow
andSetOverflow
- TextColour¶
See
GetTextColour
andSetTextColour