wxPython: some help with Drag&Drop

Stef Mientki stef.mientki at gmail.com
Mon Mar 10 18:40:27 EDT 2008


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
>
>   




More information about the Python-list mailing list