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
Trueif 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 returnsTrueand GetAlignment should returnswx.ALIGN_LEFTfor 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
DecRefonce will delete it.Calling
IncRefallows locking it until the matchingDecRefis 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.SetDefaultCellAlignmentbut is left and top by default).Notice that hAlign and vAlign values are always overwritten by this function, use
GetNonDefaultAlignmentif 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
DecRefon the returned pointer, useGetEditorPtrto 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 callDecRefmanually.- 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.IsSpecifiedalways returnsTrue. The default value, ifSetFitModehadn’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
GetAlignmentthis 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
Trueif the cells using this attribute overflow into the neighbouring cells.Prefer using
GetFitModein the new code.- Return type:
bool
- GetRenderer(self, grid, row, col)¶
Returns the cell renderer.
The caller is responsible for calling
DecRefon the returned pointer, useGetRendererPtrto 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
Trueif this attribute has a valid alignment set.- Return type:
bool
- HasBackgroundColour(self)¶
Returns
Trueif this attribute has a valid background colour set.- Return type:
bool
- HasEditor(self)¶
Returns
Trueif this attribute has a valid cell editor set.- Return type:
bool
- HasFont(self)¶
Returns
Trueif this attribute has a valid font set.- Return type:
bool
- HasOverflowMode(self)¶
- Return type:
bool
- HasReadWriteMode(self)¶
- Return type:
bool
- HasRenderer(self)¶
Returns
Trueif this attribute has a valid cell renderer set.- Return type:
bool
- HasSize(self)¶
- Return type:
bool
- HasTextColour(self)¶
Returns
Trueif 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
DecRefonce will delete it.Calling
IncRefallows locking it until the matchingDecRefis called.- Return type:
None
- IsReadOnly(self)¶
Returns
Trueif 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_CENTREorALIGN_RIGHTand vAlign can be one ofALIGN_TOP,ALIGN_CENTREorALIGN_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
SetFitModewith eitherwx.grid.GridFitMode.Overfloworwx.grid.GridFitMode.Clipargument depending on whether allow isTrueorFalse.Prefer using
SetFitModedirectly 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
DecRefcan delete us.- Return type:
None
Properties¶
- BackgroundColour¶
- FitMode¶
See
GetFitModeandSetFitMode
- Overflow¶
See
GetOverflowandSetOverflow
- TextColour¶
See
GetTextColourandSetTextColour
