.. 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.DropSource: ========================================================================================================================================== |phoenix_title| **wx.DropSource** ========================================================================================================================================== This class represents a source for a drag and drop operation. .. seealso:: :ref:`Drag and Drop Overview `, :ref:`DataObject Overview `, :ref:`wx.DropTarget`, :ref:`wx.TextDropTarget`, :ref:`wx.FileDropTarget` | |class_hierarchy| Class Hierarchy ================================= .. raw:: html
Inheritance diagram for class DropSource:
| |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: :html:`

` **__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. :html:`

` **__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. :html:`

` .. 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 `wx.Drag_AllowMove` is included in the flags, data may be moved and not only copied as is the case for the default `wx.Drag_CopyOnly` . If `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 `wx.DragCopy` , `wx.DragMove` , `wx.DragLink` , `wx.DragCancel` or `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 `wx.DragCopy` , `wx.DragMove` , `wx.DragLink` and `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/Cocoa` 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`