This class is used when you wish to drag an object on the screen, and a simple cursor is not enough.
On Windows, the Win32 API is used to achieve smooth dragging. On other platforms, GenericDragImage is used. Applications may also prefer to use GenericDragImage on Windows, too.
To use this class, when you wish to start dragging an image, create a wx.DragImage object and store it somewhere you can access it as the drag progresses. Call BeginDrag
to start, and EndDrag
to stop the drag. To move the image, initially call Show
and then Move
. If you wish to update the screen contents during the drag (for example, highlight an item as in the dragimag sample), first call Hide
, update the screen, call Move
, and then call Show
.
You can drag within one window, or you can use full-screen dragging either across the whole screen, or just restricted to one area of the screen to save resources. If you want the user to drag between two windows, then you will need to use full-screen dragging.
If you wish to draw the image yourself, use GenericDragImage and override DoDrawImage
and GetImageRect
.
See also
Drag Image Sample
__init__ |
Default constructor. |
BeginDrag |
Start dragging the image, in a window or full screen. |
EndDrag |
Call this when the drag has finished. |
Hide |
Hides the image. |
Move |
Call this to move the image to a new position. |
Show |
Shows the image. |
wx.
DragImage
(Object)¶Possible constructors:
DragImage()
DragImage(image, cursor=NullCursor)
DragImage(image, cursor=NullCursor)
DragImage(text, cursor=NullCursor)
DragImage(treeCtrl, id)
DragImage(listCtrl, id)
This class is used when you wish to drag an object on the screen, and a simple cursor is not enough.
__init__
(self, *args, **kw)¶__init__ (self)
Default constructor.
__init__ (self, image, cursor=NullCursor)
Constructs a drag image from a bitmap and optional cursor.
Parameters: |
---|
__init__ (self, image, cursor=NullCursor)
Constructs a drag image from an icon and optional cursor.
Parameters: |
---|
__init__ (self, text, cursor=NullCursor)
Constructs a drag image from a text string and optional cursor.
Parameters: |
|
---|
__init__ (self, treeCtrl, id)
Constructs a drag image from the text in the given tree control item, and optional cursor.
Parameters: |
|
---|
__init__ (self, listCtrl, id)
Constructs a drag image from the text in the given list control item, and optional cursor.
Parameters: |
|
---|
BeginDrag
(self, *args, **kw)¶BeginDrag (self, hotspot, window, fullScreen=False, rect=None)
Start dragging the image, in a window or full screen.
You need to then call Show
and Move
to show the image on the screen. Call EndDrag
when the drag has finished.
Note that this call automatically calls CaptureMouse().
Parameters: |
|
---|---|
Return type: | bool |
BeginDrag (self, hotspot, window, boundingWindow)
Start dragging the image, using the first window to capture the mouse and the second to specify the bounding area.
This form is equivalent to using the first form, but more convenient than working out the bounding rectangle explicitly.
You need to then call Show
and Move
to show the image on the screen. Call EndDrag
when the drag has finished.
Note that this call automatically calls CaptureMouse().
Parameters: | |
---|---|
Return type: | bool |
EndDrag
(self)¶Call this when the drag has finished.
Return type: | bool |
---|
Note
This function automatically releases mouse capture.
Hide
(self)¶Hides the image.
You may wish to call this before updating the window contents (perhaps highlighting an item). Then call Move
and Show
.
Return type: | bool |
---|
Move
(self, pt)¶Call this to move the image to a new position.
The image will only be shown if Show
has been called previously (for example at the start of the drag).
Parameters: | pt (wx.Point) – The position in client coordinates (relative to the window specified in BeginDrag ). |
---|---|
Return type: | bool |
Show
(self)¶Shows the image.
Call this at least once when dragging.
Return type: | bool |
---|