.. include:: headings.inc .. _DropSource: ========================================================================================================================================== |phoenix_title| **DropSource** ========================================================================================================================================== This class represents a source for a drag and drop operation. .. seealso:: :ref:`Drag and Drop Overview `, :ref:`DataObject Overview `, :ref:`DropTarget`, :ref:`TextDropTarget`, :ref:`FileDropTarget` | |class_hierarchy| Inheritance Diagram ===================================== Inheritance diagram for class **DropSource** .. raw:: html

Inheritance diagram of DropSource

| |method_summary| Methods Summary ================================ ================================================================================ ================================================================================ :meth:`~DropSource.__init__` This constructor requires that you must call :meth:`SetData` later. :meth:`~DropSource.DoDragDrop` Starts the drag-and-drop operation which will terminate when the user releases the mouse. :meth:`~DropSource.GetDataObject` Returns the :ref:`DataObject` object that has been assigned previously. :meth:`~DropSource.GiveFeedback` You may give some custom UI feedback during the drag and drop operation by overriding this function. :meth:`~DropSource.SetCursor` Set the icon to use for a certain drag result. :meth:`~DropSource.SetData` Sets the data :ref:`DataObject` associated with the drop source. :meth:`~DropSource.SetIcon` Set the icon to use for a certain drag result. ================================================================================ ================================================================================ | |property_summary| Properties Summary ===================================== ================================================================================ ================================================================================ :attr:`~DropSource.DataObject` See :meth:`~DropSource.GetDataObject` ================================================================================ ================================================================================ | |api| Class API =============== .. class:: DropSource(object) This class represents a source for a drag and drop operation. **Possible constructors**:: DropSource(win=None) DropSource(data, win=None) .. 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`: Window The icon or cursor used for feedback for copy operation. The icon or cursor used for feedback for move operation. The icon or cursor used for feedback when operation can't be done. .. availability:: Only available for MSW, OSX. **~~~** **__init__** `(self, data, win=None)` The constructor taking a :ref:`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`: DataObject :param `win`: The window which initiates the drag and drop operation. :type `win`: Window The icon or cursor used for feedback for copy operation. The icon or cursor used for feedback for move operation. The icon or cursor used for feedback when operation can't be done. .. 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 :meth:`Drag_AllowMove` is included in the flags, data may be moved and not only copied as is the case for the default :meth:`Drag_CopyOnly` . If :meth:`Drag_DefaultMove` is specified (which includes the previous flag), moving is not only possible but becomes the default operation. :type `flags`: int :rtype: :ref:`DragResult` :returns: The operation requested by the user, may be :meth:`DragCopy` , :meth:`DragMove` , :meth:`DragLink` , :meth:`DragCancel` or :meth:`DragNone` if an error occurred. .. method:: GetDataObject(self) Returns the :ref:`DataObject` object that has been assigned previously. :rtype: :ref:`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 :meth:`DragCopy` , :meth:`DragMove` , :meth:`DragLink` and :meth:`DragNone` . :type `effect`: 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`: DragResult :param `cursor`: The icon to show when this drag result occurs. :type `cursor`: Cursor MSW, OSX ports. .. availability:: Only available for MSW, OSX. .. method:: SetData(self, data) Sets the data :ref:`DataObject` associated with the drop source. This will not delete any previously associated data. :param `data`: :type `data`: 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`: DragResult :param `icon`: The icon to show when this drag result occurs. :type `icon`: Icon GTK port. .. availability:: Only available for GTK. .. attribute:: DataObject See :meth:`~DropSource.GetDataObject`