wx.DropSource¶
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
Class Hierarchy¶
Methods Summary¶
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. |
Properties Summary¶
See |
Class API¶
- class wx.DropSource(object)¶
Possible constructors:
DropSource(win=None) -> None DropSource(data, win=None) -> None
This class represents a source for a drag and drop operation.
Methods¶
- __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.- Parameters:
win (wx.Window) – The window which initiates the drag and drop operation.
- Return type:
None
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.- Parameters:
data (wx.DataObject) – The data associated with the drop source.
win (wx.Window) – The window which initiates the drag and drop operation.
- Return type:
None
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
wx.Drag_AllowMove
is included in the flags, data may be moved and not only copied as is the case for the defaultwx.Drag_CopyOnly
. Ifwx.Drag_DefaultMove
is specified (which includes the previous flag), moving is not only possible but becomes the default operation.- Return type:
- Returns:
The operation requested by the user, may be
wx.DragCopy
,wx.DragMove
,wx.DragLink
,wx.DragCancel
orwx.DragNone
if an error occurred.
- GetDataObject(self)¶
Returns the wx.DataObject object that has been assigned previously.
- Return type:
- 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
wx.DragCopy
,wx.DragMove
,wx.DragLink
andwx.DragNone
.- Return type:
bool
- Returns:
False
if you want default feedback, orTrue
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 (wx.Cursor) – The icon to show when this drag result occurs.
- Return type:
None
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.
- Parameters:
data (wx.DataObject)
- Return type:
None
- 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 (wx.Icon) – The icon to show when this drag result occurs.
- Return type:
None
GTK port.
Availability
Only available for GTK.
Properties¶
- DataObject¶
See
GetDataObject