Hello Christian,
but OnData is never called. So I can say that and where
something has been dropped but I can't access the data. What
am I doing wrong?
Uhm, can you try the slightly modified script I attach to see if it works? Don't know if this is exactly what you asked, but it seems to me it is working...
Andrea.
import wx
class Frame(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1)
self.panel = wx.Panel(self, -1)
sizer = wx.BoxSizer(wx.VERTICAL)
self.btn = wx.Button(self.panel, -1, "drop here")
sizer.Add(self.btn, 1, wx.EXPAND)
self.panel.SetAutoLayout(True)
self.panel.SetSizer(sizer)
dt = DropTarget(self.btn)
self.btn.SetDropTarget(dt)
class DropTarget(wx.PyDropTarget):
def __init__(self, window):
wx.PyDropTarget.__init__(self)
#self.do = wx.TextDataObject()
self.do = wx.CustomDataObject(wx.DataFormat(wx.DF_TEXT))
self.SetDataObject(self.do)
def OnEnter(self, x, y, d):
print 'on enter'
return d
def OnDragOver(self, x, y, d):
print 'on drag over'
return d
def OnLeave(self):
pass
def OnDrop(self, x, y):
print 'on drop'
return True
def OnData(self, x, y, d):
print 'on data'
## self.GetData()
print self.do.GetData()
return d
class App(wx.App):
def OnInit(self):
self.frame = Frame(None)
self.frame.Show(True)
return True
app = App()
app.MainLoop()
···
_________________________________________
Andrea Gavana (gavana@kpo.kz)
Reservoir Engineer
KPDL
4, Millbank
SW1P 3JA London
Direct Tel: +44 (0) 20 717 08936
Mobile Tel: +44 (0) 77 487 70534
Fax: +44 (0) 20 717 08900
Web: http://xoomer.virgilio.it/infinity77
¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯