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.
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 |
See |
|
See |
|
See |
wx.grid.
GridCellAttr
(SharedClientDataContainer, RefCounter)¶Possible constructors:
GridCellAttr(attrDefault=None)
GridCellAttr(colText, colBack, font, hAlign, vAlign)
This class can be used to alter the cells’ appearance in the grid by changing their attributes from the defaults.
__init__
(self, *args, **kw)¶__init__ (self, attrDefault=None)
Default constructor.
attrDefault (wx.grid.GridCellAttr) –
__init__ (self, colText, colBack, font, hAlign, vAlign)
Constructor specifying some of the often used attributes.
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 returns True
and GetAlignment should returns wx.ALIGN_LEFT
for hAlign parameter.
bool
New in version 4.1/wxWidgets-3.1.4.
Clone
(self)¶Creates a new copy of this object.
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 matching DecRef
is called.
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.
tuple
( hAlign, vAlign )
GetBackgroundColour
(self)¶Returns the background colour.
Colour
GetEditor
(self, grid, row, col)¶Returns the cell editor.
The caller is responsible for calling DecRef
on the returned pointer, use GetEditorPtr
to do it automatically.
grid (wx.grid.Grid) –
row (int) –
col (int) –
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 call DecRef
manually.
grid (wx.grid.Grid) –
row (int) –
col (int) –
wx.grid.GridCellEditorPtr
New 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 returns True
. The default value, if SetFitMode
hadn’t been called before, is “overflow”.
New in version 4.1/wxWidgets-3.1.4.
GetKind
(self)¶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 from wx.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()
tuple
( hAlign, vAlign )
New 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.
bool
GetRenderer
(self, grid, row, col)¶Returns the cell renderer.
The caller is responsible for calling DecRef
on the returned pointer, use GetRendererPtr
to do it automatically.
grid (wx.grid.Grid) –
row (int) –
col (int) –
GetSize
(self)¶tuple
( num_rows, num_cols )
GetTextColour
(self)¶Returns the text colour.
Colour
HasAlignment
(self)¶Returns True
if this attribute has a valid alignment set.
bool
HasBackgroundColour
(self)¶Returns True
if this attribute has a valid background colour set.
bool
HasEditor
(self)¶Returns True
if this attribute has a valid cell editor set.
bool
HasFont
(self)¶Returns True
if this attribute has a valid font set.
bool
HasOverflowMode
(self)¶bool
HasReadWriteMode
(self)¶bool
HasRenderer
(self)¶Returns True
if this attribute has a valid cell renderer set.
bool
HasSize
(self)¶bool
HasTextColour
(self)¶Returns True
if this attribute has a valid text colour set.
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 matching DecRef
is called.
IsReadOnly
(self)¶Returns True
if this cell is set as read-only.
bool
MergeWith
(self, mergefrom)¶mergefrom (wx.grid.GridCellAttr) –
SetAlignment
(self, hAlign, vAlign)¶Sets the alignment.
hAlign can be one of ALIGN_LEFT
, ALIGN_CENTRE
or ALIGN_RIGHT
and vAlign can be one of ALIGN_TOP
, ALIGN_CENTRE
or ALIGN_BOTTOM
.
hAlign (int) –
vAlign (int) –
SetDefAttr
(self, defAttr)¶defAttr (wx.grid.GridCellAttr) –
Todo
Needs documentation.
SetEditor
(self, editor)¶Sets the editor to be used with the cells with this attribute.
editor (wx.grid.GridCellEditor) –
SetFitMode
(self, fitMode)¶Specifies the behaviour of the cell contents if it doesn’t fit into the available space.
fitMode (wx.grid.GridFitMode) –
New 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 either wx.grid.GridFitMode.Overflow
or wx.grid.GridFitMode.Clip
argument depending on whether allow is True
or False
.
Prefer using SetFitMode
directly instead in the new code.
allow (bool) –
SetReadOnly
(self, isReadOnly=True)¶Sets the cell as read-only.
isReadOnly (bool) –
SetRenderer
(self, renderer)¶Sets the renderer to be used for cells with this attribute.
Takes ownership of the pointer.
renderer (wx.grid.GridCellRenderer) –
SetSize
(self, num_rows, num_cols)¶num_rows (int) –
num_cols (int) –
~wxGridCellAttr(self)
The destructor is private because only DecRef
can delete us.
BackgroundColour
¶FitMode
¶See GetFitMode
and SetFitMode
Overflow
¶See GetOverflow
and SetOverflow
TextColour
¶See GetTextColour
and SetTextColour