phoenix_title 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 Class Hierarchy

Inheritance diagram for class GridCellAttr:

method_summary Methods Summary

__init__

Default constructor.

CanOverflow

Returns True if the cell will draw an overflowed text into the neighbouring cells.

Clone

Creates a new copy of this object.

DecRef

This class is reference counted: it is created with ref count of 1, so calling DecRef once will delete it.

GetAlignment

Get the alignment to use for the cell with the given attribute.

GetBackgroundColour

Returns the background colour.

GetEditor

Returns the cell editor.

GetEditorPtr

Returns the cell editor.

GetFitMode

Returns the fitting mode for the cells using this attribute.

GetFont

Returns the font.

GetKind

GetNonDefaultAlignment

Get the alignment defined by this attribute.

GetOverflow

Returns True if the cells using this attribute overflow into the neighbouring cells.

GetRenderer

Returns the cell renderer.

GetSize

GetTextColour

Returns the text colour.

HasAlignment

Returns True if this attribute has a valid alignment set.

HasBackgroundColour

Returns True if this attribute has a valid background colour set.

HasEditor

Returns True if this attribute has a valid cell editor set.

HasFont

Returns True if this attribute has a valid font set.

HasOverflowMode

HasReadWriteMode

HasRenderer

Returns True if this attribute has a valid cell renderer set.

HasSize

HasTextColour

Returns True if this attribute has a valid text colour set.

IncRef

This class is reference counted: it is created with ref count of 1, so calling DecRef once will delete it.

IsReadOnly

Returns True if this cell is set as read-only.

MergeWith

SetAlignment

Sets the alignment.

SetBackgroundColour

Sets the background colour.

SetDefAttr

SetEditor

Sets the editor to be used with the cells with this attribute.

SetFitMode

Specifies the behaviour of the cell contents if it doesn’t fit into the available space.

SetFont

Sets the font.

SetKind

SetOverflow

Specifies if cells using this attribute should overflow or clip their contents.

SetReadOnly

Sets the cell as read-only.

SetRenderer

Sets the renderer to be used for cells with this attribute.

SetSize

SetTextColour

Sets the text colour.

~wxGridCellAttr

The destructor is private because only DecRef can delete us.


property_summary Properties Summary

BackgroundColour

See GetBackgroundColour and SetBackgroundColour

FitMode

See GetFitMode and SetFitMode

Font

See GetFont and SetFont

Kind

See GetKind and SetKind

Overflow

See GetOverflow and SetOverflow

TextColour

See GetTextColour and SetTextColour


api Class API

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


Methods

__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self, attrDefault=None)

Default constructor.

Parameters:

attrDefault (wx.grid.GridCellAttr) –



__init__ (self, colText, colBack, font, hAlign, vAlign)

Constructor specifying some of the often used attributes.

Parameters:





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.

Return type:

bool

New in version 4.1/wxWidgets-3.1.4.



Clone(self)

Creates a new copy of this object.

Return type:

wx.grid.GridCellAttr



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.

Return type:

tuple

Returns:

( hAlign, vAlign )



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, use GetEditorPtr to do it automatically.

Parameters:
Return type:

wx.grid.GridCellEditor



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.

Parameters:
Return type:

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

Return type:

wx.grid.GridFitMode

New in version 4.1/wxWidgets-3.1.4.



GetFont(self)

Returns the font.

Return type:

Font



GetKind(self)
Return type:

wx.grid.GridCellAttr.AttrKind



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()
Return type:

tuple

Returns:

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

Return type:

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.

Parameters:
Return type:

wx.grid.GridCellRenderer



GetSize(self)
Return type:

tuple

Returns:

( num_rows, num_cols )



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 matching DecRef is called.



IsReadOnly(self)

Returns True if this cell is set as read-only.

Return type:

bool



MergeWith(self, mergefrom)
Parameters:

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 .

Parameters:
  • hAlign (int) –

  • vAlign (int) –



SetBackgroundColour(self, colBack)

Sets the background colour.

Parameters:

colBack (wx.Colour) –



SetDefAttr(self, defAttr)
Parameters:

defAttr (wx.grid.GridCellAttr) –

Todo

Needs documentation.



SetEditor(self, editor)

Sets the editor to be used with the cells with this attribute.

Parameters:

editor (wx.grid.GridCellEditor) –



SetFitMode(self, fitMode)

Specifies the behaviour of the cell contents if it doesn’t fit into the available space.

Parameters:

fitMode (wx.grid.GridFitMode) –

New in version 4.1/wxWidgets-3.1.4.



SetFont(self, font)

Sets the font.

Parameters:

font (wx.Font) –



SetKind(self, kind)
Parameters:

kind (AttrKind) –



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.

Parameters:

allow (bool) –



SetReadOnly(self, isReadOnly=True)

Sets the cell as read-only.

Parameters:

isReadOnly (bool) –



SetRenderer(self, renderer)

Sets the renderer to be used for cells with this attribute.

Takes ownership of the pointer.

Parameters:

renderer (wx.grid.GridCellRenderer) –



SetSize(self, num_rows, num_cols)
Parameters:
  • num_rows (int) –

  • num_cols (int) –



SetTextColour(self, colText)

Sets the text colour.

Parameters:

colText (wx.Colour) –



~wxGridCellAttr(self)

The destructor is private because only DecRef can delete us.


Properties

BackgroundColour

See GetBackgroundColour and SetBackgroundColour



FitMode

See GetFitMode and SetFitMode



Font

See GetFont and SetFont



Kind

See GetKind and SetKind



Overflow

See GetOverflow and SetOverflow



TextColour

See GetTextColour and SetTextColour