This class represents a source for a drag and drop operation.
See also
Drag and Drop Overview, DataObject Overview, wx.DropTarget, wx.TextDropTarget, wx.FileDropTarget
This constructor requires that you must call |
|
Starts the drag-and-drop operation which will terminate when the user releases the mouse. |
|
Returns the wx.DataObject object that has been assigned previously. |
|
You may give some custom UI feedback during the drag and drop operation by overriding this function. |
|
Set the icon to use for a certain drag result. |
|
Sets the data wx.DataObject associated with the drop source. |
|
Set the icon to use for a certain drag result. |
See |
wx.
DropSource
(object)¶Possible constructors:
DropSource(win=None)
DropSource(data, win=None)
This class represents a source for a drag and drop operation.
__init__
(self, *args, **kw)¶__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.
win (wx.Window) – The window which initiates the drag and drop operation.
Availability
Only available for MSW, OSX.
__init__ (self, data, win=None)
The constructor taking a 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.
data (wx.DataObject) – The data associated with the drop source.
win (wx.Window) – The window which initiates the drag and drop operation.
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.
flags (int) – 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.
The operation requested by the user, may be wx.DragCopy
, wx.DragMove
, wx.DragLink
, wx.DragCancel
or wx.DragNone
if an error occurred.
GetDataObject
(self)¶Returns the wx.DataObject object that has been assigned previously.
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.
effect (DragResult) – The effect to implement. One of wx.DragCopy
, wx.DragMove
, wx.DragLink
and wx.DragNone
.
bool
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.
res (DragResult) – The drag result to set the icon for.
cursor (wx.Cursor) – The icon to show when this drag result occurs.
MSW, OSX/Cocoa ports.
Availability
Only available for MSW, OSX.
SetData
(self, data)¶Sets the data wx.DataObject associated with the drop source.
This will not delete any previously associated data.
data (wx.DataObject) –
SetIcon
(self, res, icon)¶Set the icon to use for a certain drag result.
res (DragResult) – The drag result to set the icon for.
icon (wx.Icon) – The icon to show when this drag result occurs.
GTK port.
Availability
Only available for GTK.
DataObject
¶See GetDataObject