[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

wxPython: some help with Drag&Drop

Eric von Horst

3/10/2008 9:04:00 PM

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

3 Answers

Mike Driscoll

3/10/2008 9:19:00 PM

0

On Mar 10, 4:04 pm, Eric von Horst <z80vsvi...@hotmail.com> wrote:
> 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/ma...

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

http://wiki.wxpython.org/D...
http://wiki.wxpython.org/Li...

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

Mike


Stef Mientki

3/10/2008 10:40:00 PM

0

Eric von Horst wrote:
> 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


>
> Erik
>
>

Jason

3/10/2008 11:11:00 PM

0



Eric von Horst wrote:
> 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