[python-win32] Creating python com objects

Alex Denham a1eio at hotmail.com
Thu Apr 24 11:28:11 CEST 2008


class PyIDropTarget:
    _public_methods_ = ['DragEnter', 'DragOver', 'DragLeave', 'Drop']
    _reg_progid_ = "Python.PyIDropTarget"
    _reg_clsid_ = '{00000122-0000-0000-C000-000000000046}'
    def DragEnter(self, args=None):
        print 'DragEnter: ', args
    def DragOver(self, args=None):
        print 'DragOver: ', args
    def DragLeave(self, args=None):
        print 'DragLeave: ', args
    def Drop(self, args=None):
        print 'Drop: ', args

Then i just used the com register thing to register it, then i tried dropTarget = win32com.client.Dispatch("Python.PyIDropTarget")
I didn't know about the pythoncomWrapObject however.


> From: rwupole at msn.com
> To: python-win32 at python.org
> Date: Wed, 23 Apr 2008 21:15:56 -0400
> Subject: [python-win32]  Creating python com objects
> 
> Alex Denham wrote:
> > Hi,
> 
> > Anybody happen to know how to go about creating a COM object that 
> > RegisterDragDrop() will actually accept?
> >
> > print dropTarget
> > <COMObject Python.PyIDropTarget>
> >
> > pythoncom.RegisterDragDrop(_id, dropTarget)
> >
> > Traceback (most recent call last):
> >   File "C:\Python25\DragAndDrop.py", line 82, in <module>
> >     main()
> >   File "C:\Python25\DragAndDrop.py", line 41, in main
> >     pythoncom.RegisterDragDrop(_id, dropTarget)
> > ValueError: argument is not a COM object
> >
> > Any help appreciated,
> >
> > Thanks
> > Alex
> 
> How was your dropTarget object created ?
> Normally, you'd create a class that implements the
> methods of IDropTarget and either register it or
> wrap it for local use using pythoncom.WrapObject.
> 
> It does look like PyIDropTarget is lacking docs, I'll
> try to improve them.  Also, the other interface you'll
> probably need (PyIDataObject) needs some
> attention in the docs.
> 
>         Roger
> 
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32

_________________________________________________________________
Bag extra points with the Walkers Brit Trip Game 
http://www.walkersbrittrips.co.uk/game
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20080424/5d0958ca/attachment-0001.htm>


More information about the python-win32 mailing list