.. wxPython Phoenix documentation

   This file was generated by Phoenix's sphinx generator and associated
   tools, do not edit by hand.

   Copyright: (c) 2011-2018 by Total Control Software
   License:   wxWindows License

.. include:: headings.inc



.. _wx.dataview.DataViewRenderer:

==========================================================================================================================================
|phoenix_title|  **wx.dataview.DataViewRenderer**
==========================================================================================================================================

This class is used by :ref:`wx.dataview.DataViewCtrl`  to render the individual cells.          

One instance of a renderer class is owned by a :ref:`wx.dataview.DataViewColumn`. There is a number of ready-to-use renderers provided:

- :ref:`wx.dataview.DataViewTextRenderer`, 
- :ref:`wx.dataview.DataViewIconTextRenderer`, 
- :ref:`wx.dataview.DataViewToggleRenderer`, 
- :ref:`wx.dataview.DataViewProgressRenderer`, 
- :ref:`wx.dataview.DataViewBitmapRenderer`, 
- :ref:`wx.dataview.DataViewDateRenderer`, 
- :ref:`wx.dataview.DataViewSpinRenderer`. 
- :ref:`wx.dataview.DataViewChoiceRenderer`. 




Additionally, the user can write their own renderers by deriving from :ref:`wx.dataview.DataViewCustomRenderer`. 

The :ref:`wx.dataview.DataViewCellMode`  and :ref:`wx.dataview.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| Class Hierarchy
=================================

.. raw:: html

   <div id="toggleBlock" onclick="return toggleVisibility(this)" class="closed" style="cursor:pointer;">
   <img id="toggleBlock-trigger" src="_static/images/closed.png"/>
   Inheritance diagram for class <strong>DataViewRenderer</strong>:
   </div>
   <div id="toggleBlock-summary" style="display:block;"></div>
   <div id="toggleBlock-content" style="display:none;">
   <p class="graphviz">
   <center><img src="_static/images/inheritance/wx.dataview.DataViewRenderer_inheritance.png" alt="Inheritance diagram of DataViewRenderer" usemap="#dummy" class="inheritance"/></center>
   </div>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.dataview.DataViewRenderer.html" title="wx.dataview.DataViewRenderer" alt="" coords="5,83,224,112"/> <area shape="rect" id="node2" href="wx.Object.html" title="wx.Object" alt="" coords="73,5,155,35"/> </map> 
   </p>

|


|sub_classes| Known Subclasses
==============================

:ref:`wx.dataview.DataViewBitmapRenderer`, :ref:`wx.dataview.DataViewChoiceRenderer`, :ref:`wx.dataview.DataViewCustomRenderer`, :ref:`wx.dataview.DataViewDateRenderer`, :ref:`wx.dataview.DataViewIconTextRenderer`, :ref:`wx.dataview.DataViewProgressRenderer`, :ref:`wx.dataview.DataViewTextRenderer`, :ref:`wx.dataview.DataViewToggleRenderer`

|


|method_summary| Methods Summary
================================

================================================================================ ================================================================================
:meth:`~wx.dataview.DataViewRenderer.__init__`                                   Constructor.
:meth:`~wx.dataview.DataViewRenderer.CancelEditing`                              
:meth:`~wx.dataview.DataViewRenderer.CreateEditorCtrl`                           
:meth:`~wx.dataview.DataViewRenderer.DisableEllipsize`                           Disable replacing parts of the item text with ellipsis.
:meth:`~wx.dataview.DataViewRenderer.EnableEllipsize`                            Enable or disable replacing parts of the item text with ellipsis to make it fit the column width.
:meth:`~wx.dataview.DataViewRenderer.FinishEditing`                              
:meth:`~wx.dataview.DataViewRenderer.GetAlignment`                               Returns the alignment.
:meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`                              
:meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`                           Returns the ellipsize mode used by the renderer.
:meth:`~wx.dataview.DataViewRenderer.GetMode`                                    Returns the cell mode.
:meth:`~wx.dataview.DataViewRenderer.GetOwner`                                   Returns pointer to the owning :ref:`wx.dataview.DataViewColumn`.
:meth:`~wx.dataview.DataViewRenderer.GetValue`                                   This methods retrieves the value from the renderer in order to transfer the value back to the data model.
:meth:`~wx.dataview.DataViewRenderer.GetValueFromEditorCtrl`                     
:meth:`~wx.dataview.DataViewRenderer.GetVariantType`                             Returns a string with the type of the :ref:`Variant`  supported by this renderer.
:meth:`~wx.dataview.DataViewRenderer.GetView`                                    
:meth:`~wx.dataview.DataViewRenderer.HasEditorCtrl`                              
:meth:`~wx.dataview.DataViewRenderer.SetAlignment`                               Sets the alignment of the renderer's content.
:meth:`~wx.dataview.DataViewRenderer.SetOwner`                                   Sets the owning :ref:`wx.dataview.DataViewColumn`.
:meth:`~wx.dataview.DataViewRenderer.SetValue`                                   Set the value of the renderer (and thus its cell) to `value`.
:meth:`~wx.dataview.DataViewRenderer.StartEditing`                               
:meth:`~wx.dataview.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:`~wx.dataview.DataViewRenderer.Alignment`                                  See :meth:`~wx.dataview.DataViewRenderer.GetAlignment` and :meth:`~wx.dataview.DataViewRenderer.SetAlignment`
:attr:`~wx.dataview.DataViewRenderer.EditorCtrl`                                 See :meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`
:attr:`~wx.dataview.DataViewRenderer.EllipsizeMode`                              See :meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`
:attr:`~wx.dataview.DataViewRenderer.Mode`                                       See :meth:`~wx.dataview.DataViewRenderer.GetMode`
:attr:`~wx.dataview.DataViewRenderer.Owner`                                      See :meth:`~wx.dataview.DataViewRenderer.GetOwner` and :meth:`~wx.dataview.DataViewRenderer.SetOwner`
:attr:`~wx.dataview.DataViewRenderer.VariantType`                                See :meth:`~wx.dataview.DataViewRenderer.GetVariantType`
================================================================================ ================================================================================


|


|api| Class API
===============


.. class:: wx.dataview.DataViewRenderer(Object)

   **Possible constructors**::

       DataViewRenderer(varianttype, mode=DATAVIEW_CELL_INERT,
                        align=DVR_DEFAULT_ALIGNMENT)
       
   
   This class is used by DataViewCtrl to render the individual cells.



   .. method:: __init__(self, varianttype, mode=DATAVIEW_CELL_INERT, align=DVR_DEFAULT_ALIGNMENT)

      Constructor.                  


      :param `varianttype`: 
      :type `varianttype`: string
      :param `mode`: 
      :type `mode`: wx.dataview.DataViewCellMode
      :param `align`: 
      :type `align`: int







   .. method:: CancelEditing(self)






   .. method:: CreateEditorCtrl(self, parent, labelRect, value)




      :param `parent`: 
      :type `parent`: wx.Window
      :param `labelRect`: 
      :type `labelRect`: wx.Rect
      :param `value`: 
      :type `value`: DVCVariant




      :rtype: :ref:`Window`








   .. 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 :ref:`wx.dataview.DataViewTextRenderer`  or :ref:`wx.dataview.DataViewIconTextRenderer`. 

      By default ``wx.ELLIPSIZE_MIDDLE`` is used. 




      :param `mode`: Ellipsization mode, use ``wx.ELLIPSIZE_NONE`` to disable.  
      :type `mode`: wx.EllipsizeMode




                  



      .. versionadded:: 2.9.1 
     








   .. method:: FinishEditing(self)



      :rtype: `bool`








   .. method:: GetAlignment(self)

      Returns the alignment.                  

      See :meth:`SetAlignment`                    

      :rtype: `int`








   .. method:: GetEditorCtrl(self)



      :rtype: :ref:`Window`








   .. method:: GetEllipsizeMode(self)

      Returns the ellipsize mode used by the renderer.                  

      If the return value is ``wx.ELLIPSIZE_NONE``, the text is simply truncated if it doesn't fit. 

                

      :rtype: :ref:`wx.EllipsizeMode`







      .. seealso:: :meth:`EnableEllipsize`     








   .. method:: GetMode(self)

      Returns the cell mode.                  

      :rtype: :ref:`wx.dataview.DataViewCellMode`








   .. method:: GetOwner(self)

      Returns pointer to the owning :ref:`wx.dataview.DataViewColumn`.                  

      :rtype: :ref:`wx.dataview.DataViewColumn`








   .. method:: GetValue(self)

      This methods retrieves the value from the renderer in order to transfer the value back to the data model.                  

      Returns ``False`` on failure.                  

      :rtype: `value`








   .. method:: GetValueFromEditorCtrl(self, editor)




      :param `editor`: 
      :type `editor`: wx.Window




      :rtype: `value`








   .. method:: GetVariantType(self)

      Returns a string with the type of the :ref:`Variant`  supported by this renderer.                  

      :rtype: `string`








   .. method:: GetView(self)



      :rtype: :ref:`wx.dataview.DataViewCtrl`








   .. method:: HasEditorCtrl(self)



      :rtype: `bool`








   .. 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:`wx.dataview.DataViewColumn`.                  

      This is usually called from within :ref:`wx.dataview.DataViewColumn`.                  


      :param `owner`: 
      :type `owner`: wx.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`: :class:`DVCVariant`




      :rtype: `bool`








   .. method:: StartEditing(self, item, labelRect)




      :param `item`: 
      :type `item`: wx.dataview.DataViewItem
      :param `labelRect`: 
      :type `labelRect`: wx.Rect




      :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`: DVCVariant




      :rtype: `bool`








   .. attribute:: Alignment

      See :meth:`~wx.dataview.DataViewRenderer.GetAlignment` and :meth:`~wx.dataview.DataViewRenderer.SetAlignment`


   .. attribute:: EditorCtrl

      See :meth:`~wx.dataview.DataViewRenderer.GetEditorCtrl`


   .. attribute:: EllipsizeMode

      See :meth:`~wx.dataview.DataViewRenderer.GetEllipsizeMode`


   .. attribute:: Mode

      See :meth:`~wx.dataview.DataViewRenderer.GetMode`


   .. attribute:: Owner

      See :meth:`~wx.dataview.DataViewRenderer.GetOwner` and :meth:`~wx.dataview.DataViewRenderer.SetOwner`


   .. attribute:: VariantType

      See :meth:`~wx.dataview.DataViewRenderer.GetVariantType`

