.. wxPython Phoenix documentation

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

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

.. include:: headings.inc



.. _wx.DropSource:

==========================================================================================================================================
|phoenix_title|  **wx.DropSource**
==========================================================================================================================================

This class represents a source for a drag and drop operation.          







         



.. seealso:: :ref:`Drag and Drop Overview <drag and drop overview>`, :ref:`DataObject Overview <dataobject overview>`, :ref:`wx.DropTarget`, :ref:`wx.TextDropTarget`, :ref:`wx.FileDropTarget`    







|

|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>DropSource</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.DropSource_inheritance.png" alt="Inheritance diagram of DropSource" 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.DropSource.html" title="wx.DropSource" alt="" coords="5,5,123,35"/> </map> 
   </p>

|


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

================================================================================ ================================================================================
:meth:`~wx.DropSource.__init__`                                                  This constructor requires that you must call :meth:`~DropSource.SetData`   later.
:meth:`~wx.DropSource.DoDragDrop`                                                Starts the drag-and-drop operation which will terminate when the user releases the mouse.
:meth:`~wx.DropSource.GetDataObject`                                             Returns the :ref:`wx.DataObject`  object that has been assigned previously.
:meth:`~wx.DropSource.GiveFeedback`                                              You may give some custom UI feedback during the drag and drop operation by overriding this function.
:meth:`~wx.DropSource.SetCursor`                                                 Set the icon to use for a certain drag result.
:meth:`~wx.DropSource.SetData`                                                   Sets the data :ref:`wx.DataObject`  associated with the drop source.
:meth:`~wx.DropSource.SetIcon`                                                   Set the icon to use for a certain drag result.
================================================================================ ================================================================================


|


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

================================================================================ ================================================================================
:attr:`~wx.DropSource.DataObject`                                                See :meth:`~wx.DropSource.GetDataObject`
================================================================================ ================================================================================


|


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


.. class:: wx.DropSource(object)

   **Possible constructors**::

       DropSource(win=None)
       
       DropSource(data, win=None)
       
   
   This class represents a source for a drag and drop operation.



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



      |overload| Overloaded Implementations:

      **~~~**

      
      **__init__** `(self, win=None)`
      
      This constructor requires that you must call :meth:`SetData`   later.                  
      
      Note that the type of `iconCopy`  and subsequent parameters differs between different ports: these are cursors under Windows and OS X but icons for GTK. You should use the macro ``DROP_ICON``  in portable programs instead of directly using either of these types. 
      
      
      
      
      
      
      :param `win`: The window which initiates the drag and drop operation.   
      :type `win`: wx.Window
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      .. availability:: Only available for MSW, OSX.  
      
      
      
      
      
      
      
      **~~~**

      
      **__init__** `(self, data, win=None)`
      
      The constructor taking a :ref:`wx.DataObject`.                  
      
      Note that the type of `iconCopy`  and subsequent parameters differs between different ports: these are cursors under Windows and OS X but icons for GTK. You should use the macro ``DROP_ICON``  in portable programs instead of directly using either of these types. 
      
      
      
      
      
      
      :param `data`: The data associated with the drop source.   
      :type `data`: wx.DataObject
      :param `win`: The window which initiates the drag and drop operation.   
      :type `win`: wx.Window
      
      
      
      
      
      
      
      
      
      
      
      
                        
      
      
      
      .. availability:: Only available for MSW, OSX.  
      
      
      
      
      
      
      
      **~~~**






   .. method:: DoDragDrop(self, flags=Drag_CopyOnly)

      Starts the drag-and-drop operation which will terminate when the user releases the mouse.                  

      Call this in response to a mouse button press, for example. 




      :param `flags`: If :ref:`wx.Drag_AllowMove`  is included in the flags, data may be moved and not only copied as is the case for the default :ref:`wx.Drag_CopyOnly`. If :ref:`wx.Drag_DefaultMove`  is specified (which includes the previous flag), moving is not only possible but becomes the default operation.  
      :type `flags`: int






      :rtype: :ref:`wx.DragResult`



                  



      :returns: 

         The operation requested by the user, may be :ref:`wx.DragCopy`, :ref:`wx.DragMove`, :ref:`wx.DragLink`, :ref:`wx.DragCancel`  or :ref:`wx.DragNone`  if an error occurred.   








   .. method:: GetDataObject(self)

      Returns the :ref:`wx.DataObject`  object that has been assigned previously.                  

      :rtype: :ref:`wx.DataObject`








   .. method:: GiveFeedback(self, effect)

      You may give some custom UI feedback during the drag and drop operation by overriding this function.                  

      It is called on each mouse move, so your implementation must not be too slow. 




      :param `effect`: The effect to implement. One of :ref:`wx.DragCopy`, :ref:`wx.DragMove`, :ref:`wx.DragLink`  and :ref:`wx.DragNone`.  
      :type `effect`: wx.DragResult






      :rtype: `bool`



                  



      :returns: 

         ``False`` if you want default feedback, or ``True`` if you implement your own feedback. The return value is ignored under GTK.   








   .. method:: SetCursor(self, res, cursor)

      Set the icon to use for a certain drag result.                  




      :param `res`: The drag result to set the icon for.   
      :type `res`: wx.DragResult
      :param `cursor`: The icon to show when this drag result occurs.  
      :type `cursor`: wx.Cursor






      MSW, OSX ports.                   



      .. availability:: Only available for MSW, OSX.  








   .. method:: SetData(self, data)

      Sets the data :ref:`wx.DataObject`  associated with the drop source.                  

      This will not delete any previously associated data.                  


      :param `data`: 
      :type `data`: wx.DataObject







   .. method:: SetIcon(self, res, icon)

      Set the icon to use for a certain drag result.                  




      :param `res`: The drag result to set the icon for.   
      :type `res`: wx.DragResult
      :param `icon`: The icon to show when this drag result occurs.  
      :type `icon`: wx.Icon






      GTK port.                   



      .. availability:: Only available for GTK.  








   .. attribute:: DataObject

      See :meth:`~wx.DropSource.GetDataObject`

