.. 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.dataview.DataViewEvent:

==========================================================================================================================================
|phoenix_title|  **wx.dataview.DataViewEvent**
==========================================================================================================================================

This is the event class for the :ref:`wx.dataview.DataViewCtrl`  notifications.          

^^ 





.. _DataViewEvent-events:

|events| Events Emitted by this Class
=====================================

Handlers bound for the following event types will receive a :ref:`wx.dataview.DataViewEvent` parameter.

Event macros: 

- EVT_DATAVIEW_SELECTION_CHANGED: Process a  ``wxEVT_DATAVIEW_SELECTION_CHANGED``   event.   
- EVT_DATAVIEW_ITEM_ACTIVATED: Process a  ``wxEVT_DATAVIEW_ITEM_ACTIVATED``   event.   
- EVT_DATAVIEW_ITEM_EDITING_STARTED: Process a  ``wxEVT_DATAVIEW_ITEM_EDITING_STARTED``   event.   
- EVT_DATAVIEW_ITEM_EDITING_DONE: Process a  ``wxEVT_DATAVIEW_ITEM_EDITING_DONE``   event.   
- EVT_DATAVIEW_ITEM_COLLAPSING: Process a  ``wxEVT_DATAVIEW_ITEM_COLLAPSING``   event.   
- EVT_DATAVIEW_ITEM_COLLAPSED: Process a  ``wxEVT_DATAVIEW_ITEM_COLLAPSED``   event.   
- EVT_DATAVIEW_ITEM_EXPANDING: Process a  ``wxEVT_DATAVIEW_ITEM_EXPANDING``   event.   
- EVT_DATAVIEW_ITEM_EXPANDED: Process a  ``wxEVT_DATAVIEW_ITEM_EXPANDED``   event.   
- EVT_DATAVIEW_ITEM_VALUE_CHANGED: Process a  ``wxEVT_DATAVIEW_ITEM_VALUE_CHANGED``   event.   
- EVT_DATAVIEW_ITEM_CONTEXT_MENU: Process a  ``wxEVT_DATAVIEW_ITEM_CONTEXT_MENU``   event.   
- EVT_DATAVIEW_COLUMN_HEADER_CLICK: Process a  ``wxEVT_DATAVIEW_COLUMN_HEADER_CLICK``   event.   
- EVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK: Process a  ``wxEVT_DATAVIEW_COLUMN_HEADER_RIGHT_CLICK``   event.   
- EVT_DATAVIEW_COLUMN_SORTED: Process a  ``wxEVT_DATAVIEW_COLUMN_SORTED``   event.   
- EVT_DATAVIEW_COLUMN_REORDERED: Process a  ``wxEVT_DATAVIEW_COLUMN_REORDERED``   event. Currently this event is not generated when using the native GTK+ version of the control.   
- EVT_DATAVIEW_ITEM_BEGIN_DRAG: Process a  ``wxEVT_DATAVIEW_ITEM_BEGIN_DRAG``   event which is generated when the user starts dragging a valid item. This event must be processed and  :meth:`wx.dataview.DataViewEvent.SetDataObject`   must be called to actually start dragging the item.  
- EVT_DATAVIEW_ITEM_DROP_POSSIBLE: Process a  ``wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE``   event.   
- EVT_DATAVIEW_ITEM_DROP: Process a  ``wxEVT_DATAVIEW_ITEM_DROP``   event.   
- EVT_DATAVIEW_CACHE_HINT: Process a  ``wxEVT_DATAVIEW_CACHE_HINT``   event. ^^ 








|

|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>DataViewEvent</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.DataViewEvent_inheritance.png" alt="Inheritance diagram of DataViewEvent" usemap="#dummy" class="inheritance"/></center>
   <script type="text/javascript">toggleVisibilityOnLoad(document.getElementById('toggleBlock'))</script>
   <map id="dummy" name="dummy"> <area shape="rect" id="node1" href="wx.dataview.DataViewEvent.html" title="wx.dataview.DataViewEvent" alt="" coords="5,315,213,344"/> <area shape="rect" id="node2" href="wx.NotifyEvent.html" title="wx.NotifyEvent" alt="" coords="48,237,171,267"/> <area shape="rect" id="node3" href="wx.CommandEvent.html" title="wx.CommandEvent" alt="" coords="35,160,184,189"/> <area shape="rect" id="node4" href="wx.Event.html" title="wx.Event" alt="" coords="68,83,151,112"/> <area shape="rect" id="node5" href="wx.Object.html" title="wx.Object" alt="" coords="66,5,153,35"/> </map> 
   </p>
   </div>

|


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

================================================================================ ================================================================================
:meth:`~wx.dataview.DataViewEvent.__init__`                                      Default constructor, normally shouldn't be used and mostly exists only for backwards compatibility.
:meth:`~wx.dataview.DataViewEvent.GetCacheFrom`                                  Return the first row that will be displayed.
:meth:`~wx.dataview.DataViewEvent.GetCacheTo`                                    Return the last row that will be displayed.
:meth:`~wx.dataview.DataViewEvent.GetColumn`                                     Returns the position of the column in the control or -1 if column field is unavailable for this event.
:meth:`~wx.dataview.DataViewEvent.GetDataBuffer`                                 Gets the data buffer for a drop data transfer
:meth:`~wx.dataview.DataViewEvent.GetDataFormat`                                 Gets the :ref:`wx.DataFormat`  during a drop operation.
:meth:`~wx.dataview.DataViewEvent.GetDataObject`                                 
:meth:`~wx.dataview.DataViewEvent.GetDataSize`                                   Gets the data size for a drop data transfer.
:meth:`~wx.dataview.DataViewEvent.GetDataViewColumn`                             Returns a pointer to the :ref:`wx.dataview.DataViewColumn`  from which the event was emitted or ``None``.
:meth:`~wx.dataview.DataViewEvent.GetDragFlags`                                  
:meth:`~wx.dataview.DataViewEvent.GetDropEffect`                                 Returns the effect the user requested to happen to the dropped data.
:meth:`~wx.dataview.DataViewEvent.GetItem`                                       Returns the item affected by the event.
:meth:`~wx.dataview.DataViewEvent.GetModel`                                      Returns the :ref:`wx.dataview.DataViewModel`  associated with the event.
:meth:`~wx.dataview.DataViewEvent.GetPosition`                                   Returns the position of a context menu event in client coordinates.
:meth:`~wx.dataview.DataViewEvent.GetProposedDropIndex`                          Returns the index of the child item at which an item currently being dragged would be dropped.
:meth:`~wx.dataview.DataViewEvent.GetValue`                                      Returns a reference to a value.
:meth:`~wx.dataview.DataViewEvent.IsEditCancelled`                               Can be used to determine whether the new value is going to be accepted in wxEVT_DATAVIEW_ITEM_EDITING_DONE handler.
:meth:`~wx.dataview.DataViewEvent.SetCache`                                      
:meth:`~wx.dataview.DataViewEvent.SetColumn`                                     Sets the column index associated with this event.
:meth:`~wx.dataview.DataViewEvent.SetDataBuffer`                                 
:meth:`~wx.dataview.DataViewEvent.SetDataFormat`                                 
:meth:`~wx.dataview.DataViewEvent.SetDataObject`                                 Set :ref:`wx.DataObject`  for data transfer within a drag operation.
:meth:`~wx.dataview.DataViewEvent.SetDataSize`                                   
:meth:`~wx.dataview.DataViewEvent.SetDataViewColumn`                             For  ``wxEVT_DATAVIEW_COLUMN_HEADER_CLICK``   only.
:meth:`~wx.dataview.DataViewEvent.SetDragFlags`                                  Specify the kind of the drag operation to perform.
:meth:`~wx.dataview.DataViewEvent.SetDropEffect`                                 
:meth:`~wx.dataview.DataViewEvent.SetItem`                                       
:meth:`~wx.dataview.DataViewEvent.SetModel`                                      Sets the dataview model associated with this event.
:meth:`~wx.dataview.DataViewEvent.SetPosition`                                   
:meth:`~wx.dataview.DataViewEvent.SetValue`                                      Sets the value associated with this event.
================================================================================ ================================================================================


|


|property_summary| Properties Summary
=====================================

================================================================================ ================================================================================
:attr:`~wx.dataview.DataViewEvent.CacheFrom`                                     See :meth:`~wx.dataview.DataViewEvent.GetCacheFrom`
:attr:`~wx.dataview.DataViewEvent.CacheTo`                                       See :meth:`~wx.dataview.DataViewEvent.GetCacheTo`
:attr:`~wx.dataview.DataViewEvent.Column`                                        See :meth:`~wx.dataview.DataViewEvent.GetColumn` and :meth:`~wx.dataview.DataViewEvent.SetColumn`
:attr:`~wx.dataview.DataViewEvent.DataBuffer`                                    See :meth:`~wx.dataview.DataViewEvent.GetDataBuffer` and :meth:`~wx.dataview.DataViewEvent.SetDataBuffer`
:attr:`~wx.dataview.DataViewEvent.DataFormat`                                    See :meth:`~wx.dataview.DataViewEvent.GetDataFormat` and :meth:`~wx.dataview.DataViewEvent.SetDataFormat`
:attr:`~wx.dataview.DataViewEvent.DataObject`                                    See :meth:`~wx.dataview.DataViewEvent.GetDataObject` and :meth:`~wx.dataview.DataViewEvent.SetDataObject`
:attr:`~wx.dataview.DataViewEvent.DataSize`                                      See :meth:`~wx.dataview.DataViewEvent.GetDataSize` and :meth:`~wx.dataview.DataViewEvent.SetDataSize`
:attr:`~wx.dataview.DataViewEvent.DataViewColumn`                                See :meth:`~wx.dataview.DataViewEvent.GetDataViewColumn` and :meth:`~wx.dataview.DataViewEvent.SetDataViewColumn`
:attr:`~wx.dataview.DataViewEvent.DragFlags`                                     See :meth:`~wx.dataview.DataViewEvent.GetDragFlags` and :meth:`~wx.dataview.DataViewEvent.SetDragFlags`
:attr:`~wx.dataview.DataViewEvent.DropEffect`                                    See :meth:`~wx.dataview.DataViewEvent.GetDropEffect` and :meth:`~wx.dataview.DataViewEvent.SetDropEffect`
:attr:`~wx.dataview.DataViewEvent.Item`                                          See :meth:`~wx.dataview.DataViewEvent.GetItem` and :meth:`~wx.dataview.DataViewEvent.SetItem`
:attr:`~wx.dataview.DataViewEvent.Model`                                         See :meth:`~wx.dataview.DataViewEvent.GetModel` and :meth:`~wx.dataview.DataViewEvent.SetModel`
:attr:`~wx.dataview.DataViewEvent.Position`                                      See :meth:`~wx.dataview.DataViewEvent.GetPosition` and :meth:`~wx.dataview.DataViewEvent.SetPosition`
:attr:`~wx.dataview.DataViewEvent.ProposedDropIndex`                             See :meth:`~wx.dataview.DataViewEvent.GetProposedDropIndex`
:attr:`~wx.dataview.DataViewEvent.Value`                                         See :meth:`~wx.dataview.DataViewEvent.GetValue` and :meth:`~wx.dataview.DataViewEvent.SetValue`
================================================================================ ================================================================================


|


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


.. class:: wx.dataview.DataViewEvent(NotifyEvent)

   **Possible constructors**::

       DataViewEvent()
       
       DataViewEvent(evtType, dvc, column, item=DataViewItem())
       
       DataViewEvent(evtType, dvc, item)
       
       DataViewEvent(event)
       
   
   This is the event class for the DataViewCtrl notifications.



   .. method:: __init__(self, *args, **kw)



      |overload| Overloaded Implementations:

      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self)`
      
      Default constructor, normally shouldn't be used and mostly exists only for backwards compatibility.                   
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, evtType, dvc, column, item=DataViewItem())`
      
      Constructor for the events affecting columns (and possibly also items).                  
      
      
      :param `evtType`: 
      :type `evtType`: wx.EventType
      :param `dvc`: 
      :type `dvc`: wx.dataview.DataViewCtrl
      :param `column`: 
      :type `column`: wx.dataview.DataViewColumn
      :param `item`: 
      :type `item`: wx.dataview.DataViewItem
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, evtType, dvc, item)`
      
      Constructor for the events affecting only the items.                  
      
      
      :param `evtType`: 
      :type `evtType`: wx.EventType
      :param `dvc`: 
      :type `dvc`: wx.dataview.DataViewCtrl
      :param `item`: 
      :type `item`: wx.dataview.DataViewItem
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`

      
      **__init__** `(self, event)`
      
      Copy constructor.                  
      
      
      :param `event`: 
      :type `event`: wx.dataview.DataViewEvent
      
      
      
      
      
      
      :html:`<hr class="overloadsep" /><br />`






   .. method:: GetCacheFrom(self)

      Return the first row that will be displayed.                  

      :rtype: `int`








   .. method:: GetCacheTo(self)

      Return the last row that will be displayed.                  

      :rtype: `int`








   .. method:: GetColumn(self)

      Returns the position of the column in the control or -1 if column field is unavailable for this event.                  

      For wxEVT_DATAVIEW_COLUMN_REORDERED, this is the new position of the column.                  

      :rtype: `int`








   .. method:: GetDataBuffer(self)

      Gets the data buffer for a drop data transfer 

      :rtype: :ref:`PyObject`








   .. method:: GetDataFormat(self)

      Gets the :ref:`wx.DataFormat`  during a drop operation.                  

      :rtype: :ref:`DataFormat`








   .. method:: GetDataObject(self)



      :rtype: :ref:`DataObject`








   .. method:: GetDataSize(self)

      Gets the data size for a drop data transfer.                  

      :rtype: `int`








   .. method:: GetDataViewColumn(self)

      Returns a pointer to the :ref:`wx.dataview.DataViewColumn`  from which the event was emitted or ``None``.                  

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








   .. method:: GetDragFlags(self)



      :rtype: `int`








   .. method:: GetDropEffect(self)

      Returns the effect the user requested to happen to the dropped data.                  

      This function can be used inside wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE and wxEVT_DATAVIEW_ITEM_DROP handlers and returns whether the user is trying to copy (the return value is :ref:`wx.DragCopy`) or move (if the return value is :ref:`wx.DragMove`) the data. 

      Currently this is only available when using the generic version of :ref:`wx.dataview.DataViewCtrl`  (used e.g. under MSW) and always returns :ref:`wx.DragNone`  in the GTK and macOS native versions. 

                

      :rtype: :ref:`wx.DragResult`







      .. versionadded:: 2.9.4 
     








   .. method:: GetItem(self)

      Returns the item affected by the event.                  

      Notice that for  ``wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE``   and   ``wxEVT_DATAVIEW_ITEM_DROP``   event handlers, the item may be invalid, indicating that the drop is about to happen outside of the item area.                   

      :rtype: :ref:`wx.dataview.DataViewItem`








   .. method:: GetModel(self)

      Returns the :ref:`wx.dataview.DataViewModel`  associated with the event.                  

      :rtype: :ref:`wx.dataview.DataViewModel`








   .. method:: GetPosition(self)

      Returns the position of a context menu event in client coordinates.                  

      :rtype: :ref:`Point`








   .. method:: GetProposedDropIndex(self)

      Returns the index of the child item at which an item currently being dragged would be dropped.                  

      This function can be used from wxEVT_DATAVIEW_ITEM_DROP_POSSIBLE handlers to determine the exact position of the item being dropped. 

      Note that it currently always returns ``wx.NOT_FOUND`` when using native GTK implementation of this control. 

                

      :rtype: `int`







      .. versionadded:: 4.1/wxWidgets-3.1.2  
     








   .. method:: GetValue(self)

      Returns a reference to a value.                  

      :rtype: :ref:`DVCVariant`








   .. method:: IsEditCancelled(self)

      Can be used to determine whether the new value is going to be accepted in wxEVT_DATAVIEW_ITEM_EDITING_DONE handler.                  

      Returns ``True`` if editing the item was cancelled or if the user tried to enter an invalid value (refused by :meth:`wx.dataview.DataViewRenderer.Validate` ). If this method returns ``False``, it means that the value in the model is about to be changed to the new one. 

      Notice that wxEVT_DATAVIEW_ITEM_EDITING_DONE event handler can call :meth:`wx.NotifyEvent.Veto`   to prevent this from happening. 

      Currently support for setting this field and for vetoing the change is only available in the generic version of :ref:`wx.dataview.DataViewCtrl`, i.e. under MSW but not GTK nor macOS. 

                

      :rtype: `bool`







      .. versionadded:: 2.9.3 
     








   .. method:: SetCache(self, from_, to_)




      :param `from_`: 
      :type `from_`: int
      :param `to_`: 
      :type `to_`: int







   .. method:: SetColumn(self, col)

      Sets the column index associated with this event.                  


      :param `col`: 
      :type `col`: int







   .. method:: SetDataBuffer(self, buf)




      :param `buf`: 







   .. method:: SetDataFormat(self, format)




      :param `format`: 
      :type `format`: wx.DataFormat







   .. method:: SetDataObject(self, obj)

      Set :ref:`wx.DataObject`  for data transfer within a drag operation.                  

      This method must be used inside a  ``wxEVT_DATAVIEW_ITEM_BEGIN_DRAG``   handler to associate the data object to be dragged with the item. 

      Note that the control takes ownership of the data object, i.e. `obj`  must be heap-allocated and will be deleted by :ref:`wx.dataview.DataViewCtrl`  itself.                  


      :param `obj`: 
      :type `obj`: wx.DataObject







   .. method:: SetDataSize(self, size)




      :param `size`: 
      :type `size`: int







   .. method:: SetDataViewColumn(self, col)

      For  ``wxEVT_DATAVIEW_COLUMN_HEADER_CLICK``   only.                   


      :param `col`: 
      :type `col`: wx.dataview.DataViewColumn







   .. method:: SetDragFlags(self, flags)

      Specify the kind of the drag operation to perform.                  

      This method can be used inside a  ``wxEVT_DATAVIEW_ITEM_BEGIN_DRAG``   handler in order to configure the drag operation. Valid values are  :ref:`wx.Drag_CopyOnly`  (default), :ref:`wx.Drag_AllowMove`  (allow the data to be moved) and :ref:`wx.Drag_DefaultMove`. 

      Currently it is only honoured by the generic version of :ref:`wx.dataview.DataViewCtrl`  (used e.g. under MSW) and not supported by the native GTK and macOS versions. 

                


      :param `flags`: 
      :type `flags`: int






      .. versionadded:: 2.9.4 
     







      .. seealso:: :meth:`GetDropEffect`   








   .. method:: SetDropEffect(self, effect)




      :param `effect`: 
      :type `effect`: wx.DragResult







   .. method:: SetItem(self, item)




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







   .. method:: SetModel(self, model)

      Sets the dataview model associated with this event.                  


      :param `model`: 
      :type `model`: wx.dataview.DataViewModel







   .. method:: SetPosition(self, x, y)




      :param `x`: 
      :type `x`: int
      :param `y`: 
      :type `y`: int







   .. method:: SetValue(self, value)

      Sets the value associated with this event.                  


      :param `value`: 
      :type `value`: DVCVariant







   .. attribute:: CacheFrom

      See :meth:`~wx.dataview.DataViewEvent.GetCacheFrom`


   .. attribute:: CacheTo

      See :meth:`~wx.dataview.DataViewEvent.GetCacheTo`


   .. attribute:: Column

      See :meth:`~wx.dataview.DataViewEvent.GetColumn` and :meth:`~wx.dataview.DataViewEvent.SetColumn`


   .. attribute:: DataBuffer

      See :meth:`~wx.dataview.DataViewEvent.GetDataBuffer` and :meth:`~wx.dataview.DataViewEvent.SetDataBuffer`


   .. attribute:: DataFormat

      See :meth:`~wx.dataview.DataViewEvent.GetDataFormat` and :meth:`~wx.dataview.DataViewEvent.SetDataFormat`


   .. attribute:: DataObject

      See :meth:`~wx.dataview.DataViewEvent.GetDataObject` and :meth:`~wx.dataview.DataViewEvent.SetDataObject`


   .. attribute:: DataSize

      See :meth:`~wx.dataview.DataViewEvent.GetDataSize` and :meth:`~wx.dataview.DataViewEvent.SetDataSize`


   .. attribute:: DataViewColumn

      See :meth:`~wx.dataview.DataViewEvent.GetDataViewColumn` and :meth:`~wx.dataview.DataViewEvent.SetDataViewColumn`


   .. attribute:: DragFlags

      See :meth:`~wx.dataview.DataViewEvent.GetDragFlags` and :meth:`~wx.dataview.DataViewEvent.SetDragFlags`


   .. attribute:: DropEffect

      See :meth:`~wx.dataview.DataViewEvent.GetDropEffect` and :meth:`~wx.dataview.DataViewEvent.SetDropEffect`


   .. attribute:: Item

      See :meth:`~wx.dataview.DataViewEvent.GetItem` and :meth:`~wx.dataview.DataViewEvent.SetItem`


   .. attribute:: Model

      See :meth:`~wx.dataview.DataViewEvent.GetModel` and :meth:`~wx.dataview.DataViewEvent.SetModel`


   .. attribute:: Position

      See :meth:`~wx.dataview.DataViewEvent.GetPosition` and :meth:`~wx.dataview.DataViewEvent.SetPosition`


   .. attribute:: ProposedDropIndex

      See :meth:`~wx.dataview.DataViewEvent.GetProposedDropIndex`


   .. attribute:: Value

      See :meth:`~wx.dataview.DataViewEvent.GetValue` and :meth:`~wx.dataview.DataViewEvent.SetValue`

