.. include:: headings.inc .. currentmodule:: dataview .. _dataview.DataViewRenderer: ========================================================================================================================================== |phoenix_title| **DataViewRenderer** ========================================================================================================================================== This class is used by :ref:`dataview.DataViewCtrl` to render the individual cells. One instance of a renderer class is owned by a :ref:`dataview.DataViewColumn`. There is a number of ready-to-use renderers provided: - `DataViewTextRenderer`, - `DataViewIconTextRenderer`, - `DataViewToggleRenderer`, - `DataViewProgressRenderer`, - `DataViewBitmapRenderer`, - `DataViewDateRenderer`, - `DataViewSpinRenderer`. - `DataViewChoiceRenderer`. Additionally, the user can write own renderers by deriving from `DataViewCustomRenderer`. The :meth:`~dataview.DataViewRenderer.DataViewCellMode` and :meth:`~dataview.DataViewRenderer.DataViewCellRenderState` flags accepted by the constructors respectively controls what actions the cell data allows and how the renderer should display its contents in a cell. | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **DataViewRenderer** .. raw:: html

Inheritance diagram of DataViewRenderer

| |sub_classes| Known Subclasses ============================== `DataViewBitmapRenderer`, `DataViewChoiceRenderer`, `DataViewCustomRenderer`, `DataViewDateRenderer`, `DataViewIconTextRenderer`, `DataViewProgressRenderer`, `DataViewTextRenderer`, `DataViewToggleRenderer` | |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~DataViewRenderer.__init__` Constructor. :meth:`~DataViewRenderer.DisableEllipsize` Disable replacing parts of the item text with ellipsis. :meth:`~DataViewRenderer.EnableEllipsize` Enable or disable replacing parts of the item text with ellipsis to make it fit the column width. :meth:`~DataViewRenderer.GetAlignment` Returns the alignment. :meth:`~DataViewRenderer.GetEllipsizeMode` Returns the ellipsize mode used by the renderer. :meth:`~DataViewRenderer.GetMode` Returns the cell mode. :meth:`~DataViewRenderer.GetOwner` Returns pointer to the owning :ref:`dataview.DataViewColumn`. :meth:`~DataViewRenderer.GetValue` This methods retrieves the value from the renderer in order to transfer the value back to the data model. :meth:`~DataViewRenderer.GetVariantType` Returns a string with the type of the `Variant` supported by this renderer. :meth:`~DataViewRenderer.SetAlignment` Sets the alignment of the renderer's content. :meth:`~DataViewRenderer.SetOwner` Sets the owning :ref:`dataview.DataViewColumn`. :meth:`~DataViewRenderer.SetValue` Set the value of the renderer (and thus its cell) to `value`. :meth:`~DataViewRenderer.Validate` Before data is committed to the data model, it is passed to this method where it can be checked for validity. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~DataViewRenderer.Alignment` See :meth:`~DataViewRenderer.GetAlignment` and :meth:`~DataViewRenderer.SetAlignment` :attr:`~DataViewRenderer.EllipsizeMode` See :meth:`~DataViewRenderer.GetEllipsizeMode` :attr:`~DataViewRenderer.Mode` See :meth:`~DataViewRenderer.GetMode` :attr:`~DataViewRenderer.Owner` See :meth:`~DataViewRenderer.GetOwner` and :meth:`~DataViewRenderer.SetOwner` :attr:`~DataViewRenderer.VariantType` See :meth:`~DataViewRenderer.GetVariantType` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: DataViewRenderer(Object) This class is used by DataViewCtrl to render the individual cells. **Possible constructors**:: DataViewRenderer(varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT) .. method:: __init__(self, varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT) Constructor. :param `varianttype`: :type `varianttype`: string :param `mode`: :type `mode`: DataViewCellMode :param `align`: :type `align`: int .. method:: DisableEllipsize(self) Disable replacing parts of the item text with ellipsis. If ellipsizing is disabled, the string will be truncated if it doesn't fit. This is the same as :: EnableEllipsize(wx.ELLIPSIZE_NONE) .. versionadded:: 2.9.1 .. method:: EnableEllipsize(self, mode=ELLIPSIZE_MIDDLE) Enable or disable replacing parts of the item text with ellipsis to make it fit the column width. This method only makes sense for the renderers working with text, such as `DataViewTextRenderer` or `DataViewIconTextRenderer`. By default ``ELLIPSIZE_MIDDLE`` is used. :param `mode`: Ellipsization mode, use ``ELLIPSIZE_NONE`` to disable. :type `mode`: EllipsizeMode .. versionadded:: 2.9.1 .. method:: GetAlignment(self) Returns the alignment. See :meth:`SetAlignment` :rtype: `int` .. method:: GetEllipsizeMode(self) Returns the ellipsize mode used by the renderer. If the return value is ``ELLIPSIZE_NONE``, the text is simply truncated if it doesn't fit. :rtype: :ref:`EllipsizeMode` .. seealso:: :meth:`EnableEllipsize` .. method:: GetMode(self) Returns the cell mode. :rtype: `DataViewCellMode` .. method:: GetOwner(self) Returns pointer to the owning :ref:`dataview.DataViewColumn`. :rtype: :ref:`dataview.DataViewColumn` .. method:: GetValue(self, value) This methods retrieves the value from the renderer in order to transfer the value back to the data model. Returns ``False`` on failure. :param `value`: :type `value`: Variant :rtype: `bool` .. method:: GetVariantType(self) Returns a string with the type of the `Variant` supported by this renderer. :rtype: `string` .. method:: SetAlignment(self, align) Sets the alignment of the renderer's content. The default value of ``DVR_DEFAULT_ALIGMENT`` indicates that the content should have the same alignment as the column header. The method is not implemented under OS X and the renderer always aligns its contents as the column header on that platform. The other platforms support both vertical and horizontal alignment. :param `align`: :type `align`: int .. method:: SetOwner(self, owner) Sets the owning :ref:`dataview.DataViewColumn`. This is usually called from within :ref:`dataview.DataViewColumn`. :param `owner`: :type `owner`: dataview.DataViewColumn .. method:: SetValue(self, value) Set the value of the renderer (and thus its cell) to `value`. The internal code will then render this cell with this data. :param `value`: :type `value`: Variant :rtype: `bool` .. method:: Validate(self, value) Before data is committed to the data model, it is passed to this method where it can be checked for validity. This can also be used for checking a valid range or limiting the user input in a certain aspect (e.g. max number of characters or only alphanumeric input, ``ASCII`` only etc.). Return ``False`` if the value is not valid. Please note that due to implementation limitations, this validation is done after the editing control already is destroyed and the editing process finished. :param `value`: :type `value`: Variant :rtype: `bool` .. attribute:: Alignment See :meth:`~DataViewRenderer.GetAlignment` and :meth:`~DataViewRenderer.SetAlignment` .. attribute:: EllipsizeMode See :meth:`~DataViewRenderer.GetEllipsizeMode` .. attribute:: Mode See :meth:`~DataViewRenderer.GetMode` .. attribute:: Owner See :meth:`~DataViewRenderer.GetOwner` and :meth:`~DataViewRenderer.SetOwner` .. attribute:: VariantType See :meth:`~DataViewRenderer.GetVariantType`