wxPython: some help with Drag&Drop

E

Eric von Horst

Hi,

I need some advice on Drag&Drop.

What I want to achieve is the following:
- I have a window that is divided in two : on the left hand I
have a wx.TreeCtlr and on the other hand a wx.StaticBitmap

I want to be able to drag an item from the tree onto the static
bitmap.

I know how to do drag&drop in a treeCtrl but is there a way that I can
make the bitmap detect that something has been dropped on it?

I would only need to know the name of the tree obj that was dropped on
the bitmap (and the location)

Any help much appreciated



Erik
 
M

Mike Driscoll

Hi,

I need some advice on Drag&Drop.

What I want to achieve is the following:
- I have a window that is divided in two : on the left hand I
have a wx.TreeCtlr and on the other hand a wx.StaticBitmap

I want to be able to drag an item from the tree onto the static
bitmap.

I know how to do drag&drop in a treeCtrl but is there a way that I can
make the bitmap detect that something has been dropped on it?

I would only need to know the name of the tree obj that was dropped on
the bitmap (and the location)

Any help much appreciated

Erik

I highly recommend posting to the wxPython user's group since they
specialize in this sort of thing: http://wxpython.org/maillist.php

In the mean time, you'll probably want to take a look at their wiki:

http://wiki.wxpython.org/DragAndDrop
http://wiki.wxpython.org/ListControls

There's also a fair amount of data on the subject in their archives.

Mike
 
S

Stef Mientki

Eric said:
Hi,

I need some advice on Drag&Drop.

What I want to achieve is the following:
- I have a window that is divided in two : on the left hand I
have a wx.TreeCtlr and on the other hand a wx.StaticBitmap

I want to be able to drag an item from the tree onto the static
bitmap.

I know how to do drag&drop in a treeCtrl but is there a way that I can
make the bitmap detect that something has been dropped on it?

I would only need to know the name of the tree obj that was dropped on
the bitmap (and the location)

Any help much appreciated
As Mike said it might be better for you (and others bumping into this
problem),
if you would post your question in the wxPython list.

Anyway here is mine solution, dragging from a tree on the left,
either on the tree itself or on a visual disign canvas right of the
splitter:
def OnEndDrag2(self, event):
item = event.GetItem()
if item:
# this is not a very elegant way, but it works
# we compare the event-position with the splitter sash-position
# to determine if it's a tree-drop or a graphical-canvas-drop
w = self.parent_form.Splitter.GetSashPosition()
x, y = event.GetPoint()
if x > w:
self.Insert_Lib_Object ( self.drag_item, x-w, y+26 )
else :


cheers,
Stef
 
J

Jason

Eric said:
Hi,

I need some advice on Drag&Drop.

What I want to achieve is the following:
- I have a window that is divided in two : on the left hand I
have a wx.TreeCtlr and on the other hand a wx.StaticBitmap

I want to be able to drag an item from the tree onto the static
bitmap.

I know how to do drag&drop in a treeCtrl but is there a way that I can
make the bitmap detect that something has been dropped on it?

I would only need to know the name of the tree obj that was dropped on
the bitmap (and the location)

Any help much appreciated



Erik

Take a look at the wxPython demo [1]. In the "Clipboard and DnD"
section, there's the "CustomDragAndDrop" demo. It sounds like that's
exactly what you want. (It uses the wx.PyDropTarget class to
accomplish this, BTW.)

[1] The demo package for your platform can be found at "http://
www.wxpython.org/download.php#binaries"

--Jason
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top