Drag and Drop in MS Windows

All-

Does anyone know how to DnD items from Outlook into a wxPython application?
Using MS tools C++ and VB it's possible to get a ref to an IDataObject
object and extract the data. Is there an equivalent way in Python?

The following code (heavily based on the Tree DnD sample from the Wiki) for
a DataObject which I then set as the DataObject in the DropTarget gets me a
little way toward my goal:

class DropDataEx(wxPyDataObjectSimple):
    def __init__(self):
        wxPyDataObjectSimple.__init__(self, wxDataFormat(0xFFFFC0AB))
        # 0xFFFFC0AB is the ClipBoard flavor of a FILEGROUPDESCRIPTOR
        self.data = None
    
    def GetDataSize(self):
        print "get data size"
        return len(self.data)
    
    def GetDataHere(self):
        print "get data here"
        return self.data

    def SetData(self, data):
        print "set data"
        self.data = "HELLO"
        return True

However, although the DropTarget will accept the drop (i.e. OnDrop returns
True and OnData is called in the DropTarget) the GetData method on the
DropTarget seems to fail and *Outlook* reports an error that 'The operation
failed due to network or other communications problems. Check your
connections and try again'. The python application doesn't report an error
but then "kinda" hangs i.e. it repaints, acknowledges certain events but
can't be shutdown and the DnD mechanism is frozen. An interesting aside: if
I derive my class from wxDataObjectSimple (rather the the python class) the
operation doesn't fail with an error. The drop is allowed, the piece of
email is deleted from Outlook, the OnData method of the DropTarget is called
but the the GetData method returns None.

Does anyone out there have any inkling how to proceed from here?

Regards

Kieran

K Owens wrote:

All-

Does anyone know how to DnD items from Outlook into a wxPython application?
Using MS tools C++ and VB it's possible to get a ref to an IDataObject
object and extract the data. Is there an equivalent way in Python?

Not from wxPython but maybe PyWin can handle it.

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!