Table Of Contents

Previous topic

DropFilesEvent

Next topic

DropTarget

This Page

phoenix_title DropSource

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


class_hierarchy Inheritance Diagram

Inheritance diagram for class DropSource

Inheritance diagram of DropSource


method_summary Methods Summary

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

property_summary Properties Summary

DataObject See 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)

Methods



__init__(self, *args, **kw)

overload Overloaded Implementations:



__init__ (self, win=None)

This constructor requires that you must call 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.

Parameters:win (Window) – The window which initiates the drag and drop operation.

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 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.

Parameters:
  • data (DataObject) – The data associated with the drop source.
  • win (Window) – The window which initiates the drag and drop operation.

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.





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.

Parameters:flags (int) – If Drag_AllowMove is included in the flags, data may be moved and not only copied as is the case for the default Drag_CopyOnly . If Drag_DefaultMove is specified (which includes the previous flag), moving is not only possible but becomes the default operation.
Return type: DragResult
Returns:The operation requested by the user, may be DragCopy , DragMove , DragLink , DragCancel or DragNone if an error occurred.


GetDataObject(self)

Returns the DataObject object that has been assigned previously.

Return type: DataObject


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.

Parameters:effect (DragResult) – The effect to implement. One of DragCopy , DragMove , DragLink and DragNone .
Return type:bool
Returns:False if you want default feedback, or True if you implement your own feedback. The return value is ignored under GTK.


SetCursor(self, res, cursor)

Set the icon to use for a certain drag result.

Parameters:
  • res (DragResult) – The drag result to set the icon for.
  • cursor (Cursor) – The icon to show when this drag result occurs.

MSW, OSX ports.

Availability

Only available for MSW, OSX.



SetData(self, data)

Sets the data DataObject associated with the drop source.

This will not delete any previously associated data.

Parameters:data (DataObject) –


SetIcon(self, res, icon)

Set the icon to use for a certain drag result.

Parameters:
  • res (DragResult) – The drag result to set the icon for.
  • icon (Icon) – The icon to show when this drag result occurs.

GTK port.

Availability

Only available for GTK.


Properties



DataObject

See GetDataObject