.. wxPython Phoenix documentation
This file was generated by Phoenix's sphinx generator and associated
tools, do not edit by hand.
Copyright: (c) 2011-2020 by Total Control Software
License: wxWindows License
.. include:: headings.inc
.. _wx.grid.GridCellAttr:
==========================================================================================================================================
|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 :meth:`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
=================================
.. raw:: html

Inheritance diagram for class
GridCellAttr:
|
|method_summary| Methods Summary
================================
================================================================================ ================================================================================
:meth:`~wx.grid.GridCellAttr.__init__` Default constructor.
:meth:`~wx.grid.GridCellAttr.CanOverflow` Returns ``True`` if the cell will draw an overflowed text into the neighbouring cells.
:meth:`~wx.grid.GridCellAttr.Clone` Creates a new copy of this object.
:meth:`~wx.grid.GridCellAttr.DecRef` This class is reference counted: it is created with ref count of 1, so calling :meth:`~GridCellAttr.DecRef` once will delete it.
:meth:`~wx.grid.GridCellAttr.GetAlignment` Get the alignment to use for the cell with the given attribute.
:meth:`~wx.grid.GridCellAttr.GetBackgroundColour` Returns the background colour.
:meth:`~wx.grid.GridCellAttr.GetEditor` Returns the cell editor.
:meth:`~wx.grid.GridCellAttr.GetEditorPtr` Returns the cell editor.
:meth:`~wx.grid.GridCellAttr.GetFitMode` Returns the fitting mode for the cells using this attribute.
:meth:`~wx.grid.GridCellAttr.GetFont` Returns the font.
:meth:`~wx.grid.GridCellAttr.GetKind`
:meth:`~wx.grid.GridCellAttr.GetNonDefaultAlignment` Get the alignment defined by this attribute.
:meth:`~wx.grid.GridCellAttr.GetOverflow` Returns ``True`` if the cells using this attribute overflow into the neighbouring cells.
:meth:`~wx.grid.GridCellAttr.GetRenderer` Returns the cell renderer.
:meth:`~wx.grid.GridCellAttr.GetSize`
:meth:`~wx.grid.GridCellAttr.GetTextColour` Returns the text colour.
:meth:`~wx.grid.GridCellAttr.HasAlignment` Returns ``True`` if this attribute has a valid alignment set.
:meth:`~wx.grid.GridCellAttr.HasBackgroundColour` Returns ``True`` if this attribute has a valid background colour set.
:meth:`~wx.grid.GridCellAttr.HasEditor` Returns ``True`` if this attribute has a valid cell editor set.
:meth:`~wx.grid.GridCellAttr.HasFont` Returns ``True`` if this attribute has a valid font set.
:meth:`~wx.grid.GridCellAttr.HasOverflowMode`
:meth:`~wx.grid.GridCellAttr.HasReadWriteMode`
:meth:`~wx.grid.GridCellAttr.HasRenderer` Returns ``True`` if this attribute has a valid cell renderer set.
:meth:`~wx.grid.GridCellAttr.HasSize`
:meth:`~wx.grid.GridCellAttr.HasTextColour` Returns ``True`` if this attribute has a valid text colour set.
:meth:`~wx.grid.GridCellAttr.IncRef` This class is reference counted: it is created with ref count of 1, so calling :meth:`~GridCellAttr.DecRef` once will delete it.
:meth:`~wx.grid.GridCellAttr.IsReadOnly` Returns ``True`` if this cell is set as read-only.
:meth:`~wx.grid.GridCellAttr.MergeWith`
:meth:`~wx.grid.GridCellAttr.SetAlignment` Sets the alignment.
:meth:`~wx.grid.GridCellAttr.SetBackgroundColour` Sets the background colour.
:meth:`~wx.grid.GridCellAttr.SetDefAttr`
:meth:`~wx.grid.GridCellAttr.SetEditor` Sets the editor to be used with the cells with this attribute.
:meth:`~wx.grid.GridCellAttr.SetFitMode` Specifies the behaviour of the cell contents if it doesn't fit into the available space.
:meth:`~wx.grid.GridCellAttr.SetFont` Sets the font.
:meth:`~wx.grid.GridCellAttr.SetKind`
:meth:`~wx.grid.GridCellAttr.SetOverflow` Specifies if cells using this attribute should overflow or clip their contents.
:meth:`~wx.grid.GridCellAttr.SetReadOnly` Sets the cell as read-only.
:meth:`~wx.grid.GridCellAttr.SetRenderer` Sets the renderer to be used for cells with this attribute.
:meth:`~wx.grid.GridCellAttr.SetSize`
:meth:`~wx.grid.GridCellAttr.SetTextColour` Sets the text colour.
:meth:`~wx.grid.GridCellAttr.~wxGridCellAttr` The destructor is private because only :meth:`~GridCellAttr.DecRef` can delete us.
================================================================================ ================================================================================
|
|property_summary| Properties Summary
=====================================
================================================================================ ================================================================================
:attr:`~wx.grid.GridCellAttr.BackgroundColour` See :meth:`~wx.grid.GridCellAttr.GetBackgroundColour` and :meth:`~wx.grid.GridCellAttr.SetBackgroundColour`
:attr:`~wx.grid.GridCellAttr.FitMode` See :meth:`~wx.grid.GridCellAttr.GetFitMode` and :meth:`~wx.grid.GridCellAttr.SetFitMode`
:attr:`~wx.grid.GridCellAttr.Font` See :meth:`~wx.grid.GridCellAttr.GetFont` and :meth:`~wx.grid.GridCellAttr.SetFont`
:attr:`~wx.grid.GridCellAttr.Kind` See :meth:`~wx.grid.GridCellAttr.GetKind` and :meth:`~wx.grid.GridCellAttr.SetKind`
:attr:`~wx.grid.GridCellAttr.Overflow` See :meth:`~wx.grid.GridCellAttr.GetOverflow` and :meth:`~wx.grid.GridCellAttr.SetOverflow`
:attr:`~wx.grid.GridCellAttr.TextColour` See :meth:`~wx.grid.GridCellAttr.GetTextColour` and :meth:`~wx.grid.GridCellAttr.SetTextColour`
================================================================================ ================================================================================
|
|api| Class API
===============
.. class:: wx.grid.GridCellAttr(SharedClientDataContainer, RefCounter)
**Possible constructors**::
GridCellAttr(attrDefault: Optional[GridCellAttr]=None) -> None
GridCellAttr(colText : Colour, colBack : Colour, font : Font, hAlign :
int, vAlign : int) -> None
This class can be used to alter the cells' appearance in the grid by
changing their attributes from the defaults.
.. method:: __init__(self, *args, **kw)
|overload| **Overloaded Implementations:**
:html:`
`
**__init__** `(self, attrDefault: Optional[GridCellAttr]=None)`
Default constructor.
:param `attrDefault`:
:type `attrDefault`: wx.grid.GridCellAttr
:rtype: `None`
:html:`
`
**__init__** `(self, colText : Colour, colBack : Colour, font : Font, hAlign : int, vAlign : int)`
Constructor specifying some of the often used attributes.
:param `colText`:
:type `colText`: wx.Colour
:param `colBack`:
:type `colBack`: wx.Colour
:param `font`:
:type `font`: wx.Font
:param `hAlign`:
:type `hAlign`: int
:param `vAlign`:
:type `vAlign`: int
:rtype: `None`
:html:`
`
.. method:: 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 :meth:`GetFitMode` .IsOverflow() should returns ``True`` and GetAlignment should returns ``wx.ALIGN_LEFT`` for hAlign parameter.
:rtype: `bool`
.. versionadded:: 4.1/wxWidgets-3.1.4
.. method:: Clone(self)
Creates a new copy of this object.
:rtype: :ref:`wx.grid.GridCellAttr`
.. method:: DecRef(self)
This class is reference counted: it is created with ref count of 1, so calling :meth:`DecRef` once will delete it.
Calling :meth:`IncRef` allows locking it until the matching :meth:`DecRef` is called.
:rtype: `None`
.. method:: 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 :meth:`wx.grid.Grid.SetDefaultCellAlignment` but is left and top by default).
Notice that `hAlign` and `vAlign` values are always overwritten by this function, use :meth:`GetNonDefaultAlignment` if this is not desirable.
:rtype: :ref:`Tuple[int, int]`
.. method:: GetBackgroundColour(self)
Returns the background colour.
:rtype: `Colour`
.. method:: GetEditor(self, grid : Grid, row : int, col : int)
Returns the cell editor.
The caller is responsible for calling :meth:`DecRef` on the returned pointer, use :meth:`GetEditorPtr` to do it automatically.
:param `grid`:
:type `grid`: wx.grid.Grid
:param `row`:
:type `row`: int
:param `col`:
:type `col`: int
:rtype: :ref:`wx.grid.GridCellEditor`
.. method:: GetEditorPtr(self, grid : Grid, row : int, col : int)
Returns the cell editor.
This method is identical to :meth:`GetEditor` , but returns a smart pointer, which frees the caller from the need to call :meth:`DecRef` manually.
:param `grid`:
:type `grid`: wx.grid.Grid
:param `row`:
:type `row`: int
:param `col`:
:type `col`: int
:rtype: `wx.grid.GridCellEditorPtr`
.. versionadded:: 4.1/wxWidgets-3.1.4
.. method:: GetFitMode(self)
Returns the fitting mode for the cells using this attribute.
The returned :ref:`wx.grid.GridFitMode` is always specified, i.e. :meth:`wx.grid.GridFitMode.IsSpecified` always returns ``True``. The default value, if :meth:`SetFitMode` hadn't been called before, is "overflow".
:rtype: :ref:`wx.grid.GridFitMode`
.. versionadded:: 4.1/wxWidgets-3.1.4
.. method:: GetFont(self)
Returns the font.
:rtype: `Font`
.. method:: GetKind(self)
:rtype: :ref:`wx.grid.GridCellAttr.AttrKind`
.. method:: GetNonDefaultAlignment(self)
Get the alignment defined by this attribute.
Unlike :meth:`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()
:rtype: :ref:`Tuple[int, int]`
.. versionadded:: 2.9.1
.. method:: GetOverflow(self)
Returns ``True`` if the cells using this attribute overflow into the neighbouring cells.
Prefer using :meth:`GetFitMode` in the new code.
:rtype: `bool`
.. method:: GetRenderer(self, grid : Grid, row : int, col : int)
Returns the cell renderer.
The caller is responsible for calling :meth:`DecRef` on the returned pointer, use :meth:`GetRendererPtr` to do it automatically.
:param `grid`:
:type `grid`: wx.grid.Grid
:param `row`:
:type `row`: int
:param `col`:
:type `col`: int
:rtype: :ref:`wx.grid.GridCellRenderer`
.. method:: GetSize(self)
:rtype: :ref:`Tuple[int, int]`
.. method:: GetTextColour(self)
Returns the text colour.
:rtype: `Colour`
.. method:: HasAlignment(self)
Returns ``True`` if this attribute has a valid alignment set.
:rtype: `bool`
.. method:: HasBackgroundColour(self)
Returns ``True`` if this attribute has a valid background colour set.
:rtype: `bool`
.. method:: HasEditor(self)
Returns ``True`` if this attribute has a valid cell editor set.
:rtype: `bool`
.. method:: HasFont(self)
Returns ``True`` if this attribute has a valid font set.
:rtype: `bool`
.. method:: HasOverflowMode(self)
:rtype: `bool`
.. method:: HasReadWriteMode(self)
:rtype: `bool`
.. method:: HasRenderer(self)
Returns ``True`` if this attribute has a valid cell renderer set.
:rtype: `bool`
.. method:: HasSize(self)
:rtype: `bool`
.. method:: HasTextColour(self)
Returns ``True`` if this attribute has a valid text colour set.
:rtype: `bool`
.. method:: IncRef(self)
This class is reference counted: it is created with ref count of 1, so calling :meth:`DecRef` once will delete it.
Calling :meth:`IncRef` allows locking it until the matching :meth:`DecRef` is called.
:rtype: `None`
.. method:: IsReadOnly(self)
Returns ``True`` if this cell is set as read-only.
:rtype: `bool`
.. method:: MergeWith(self, mergefrom : GridCellAttr)
:param `mergefrom`:
:type `mergefrom`: wx.grid.GridCellAttr
:rtype: `None`
.. method:: SetAlignment(self, hAlign : int, vAlign : int)
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`` .
:param `hAlign`:
:type `hAlign`: int
:param `vAlign`:
:type `vAlign`: int
:rtype: `None`
.. method:: SetBackgroundColour(self, colBack : Colour)
Sets the background colour.
:param `colBack`:
:type `colBack`: wx.Colour
:rtype: `None`
.. method:: SetDefAttr(self, defAttr : GridCellAttr)
:param `defAttr`:
:type `defAttr`: wx.grid.GridCellAttr
:rtype: `None`
.. todo:: Needs documentation.
.. method:: SetEditor(self, editor : GridCellEditor)
Sets the editor to be used with the cells with this attribute.
:param `editor`:
:type `editor`: wx.grid.GridCellEditor
:rtype: `None`
.. method:: SetFitMode(self, fitMode : GridFitMode)
Specifies the behaviour of the cell contents if it doesn't fit into the available space.
:param `fitMode`:
:type `fitMode`: wx.grid.GridFitMode
:rtype: `None`
.. versionadded:: 4.1/wxWidgets-3.1.4
.. seealso:: :ref:`wx.grid.GridFitMode`
.. method:: SetFont(self, font : Font)
Sets the font.
:param `font`:
:type `font`: wx.Font
:rtype: `None`
.. method:: SetKind(self, kind : AttrKind)
:param `kind`:
:type `kind`: wx.grid.GridCellAttr.AttrKind
:rtype: `None`
.. method:: SetOverflow(self, allow: bool=True)
Specifies if cells using this attribute should overflow or clip their contents.
This is the same as calling :meth:`SetFitMode` with either :meth:`wx.grid.GridFitMode.Overflow` or :meth:`wx.grid.GridFitMode.Clip` argument depending on whether `allow` is ``True`` or ``False``.
Prefer using :meth:`SetFitMode` directly instead in the new code.
:param `allow`:
:type `allow`: bool
:rtype: `None`
.. method:: SetReadOnly(self, isReadOnly: bool=True)
Sets the cell as read-only.
:param `isReadOnly`:
:type `isReadOnly`: bool
:rtype: `None`
.. method:: SetRenderer(self, renderer : GridCellRenderer)
Sets the renderer to be used for cells with this attribute.
Takes ownership of the pointer.
:param `renderer`:
:type `renderer`: wx.grid.GridCellRenderer
:rtype: `None`
.. method:: SetSize(self, num_rows : int, num_cols : int)
:param `num_rows`:
:type `num_rows`: int
:param `num_cols`:
:type `num_cols`: int
:rtype: `None`
.. method:: SetTextColour(self, colText : Colour)
Sets the text colour.
:param `colText`:
:type `colText`: wx.Colour
:rtype: `None`
.. method:: ~wxGridCellAttr(self)
The destructor is private because only :meth:`DecRef` can delete us.
.. attribute:: BackgroundColour
See :meth:`~wx.grid.GridCellAttr.GetBackgroundColour` and :meth:`~wx.grid.GridCellAttr.SetBackgroundColour`
.. attribute:: FitMode
See :meth:`~wx.grid.GridCellAttr.GetFitMode` and :meth:`~wx.grid.GridCellAttr.SetFitMode`
.. attribute:: Font
See :meth:`~wx.grid.GridCellAttr.GetFont` and :meth:`~wx.grid.GridCellAttr.SetFont`
.. attribute:: Kind
See :meth:`~wx.grid.GridCellAttr.GetKind` and :meth:`~wx.grid.GridCellAttr.SetKind`
.. attribute:: Overflow
See :meth:`~wx.grid.GridCellAttr.GetOverflow` and :meth:`~wx.grid.GridCellAttr.SetOverflow`
.. attribute:: TextColour
See :meth:`~wx.grid.GridCellAttr.GetTextColour` and :meth:`~wx.grid.GridCellAttr.SetTextColour`
.. toctree::
:maxdepth: 1
:hidden:
wx.grid.GridCellAttr.AttrKind.enumeration