Hi all,
sorry if this is a repost, but it seems that my original e-mail has
been filtered out.
I am trying to implement some DnD from a treectrl to a flatnotebook.
Everything works fine, except the implementation of OnDragOver inside
a DropTarget class.
Basically, if the dragged tree item has no associated data (empty
dictionary), I would like to have the same "barred" icon which
provides a visual feedback to the user (the dop can't be performed
because there is no data).
This is what I do:
class DropTarget(wx.DropTarget):
def __init__(self, parent):
""" Default class constructor. """
wx.DropTarget.__init__(self)
self._parent = parent
self._dataobject =
wx.CustomDataObject(wx.CustomDataFormat("SymphonyPlot"))
self.SetDataObject(self._dataobject)
def OnDragOver(self, x, y, dragres):
if not self.GetData():
return wx.DragNone
draginfo = self._dataobject.GetData()
drginfo = cPickle.loads(draginfo)
if not drginfo.GetPlotData():
return wx.DragNone
return dragres
def OnData(self, x, y, dragres):
""" Handles the OnData() method to call the real DnD routine. """
if not self.GetData():
return wx.DragNone
draginfo = self._dataobject.GetData()
drginfo = cPickle.loads(draginfo)
if not drginfo.GetPlotData():
return wx.DragNone
return self._parent.OnDropTarget(x, y, drginfo.GetPlotData())
Well, I am surely doing something stupid here, but as soon as
OnDragOver is called, Python crashes with the usual Windows error
message box. The offending line in OnDragOver is:
if not self.GetData():
return wx.DragNone
Does anyone know what I may be doing wrong?
Thank you for every hint.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.virgilio.it/infinity77/