Win32: ByRef equivalent in pythoncom for function callbacks?
Mike Fletcher
mfletch at tpresence.com
Mon Sep 25 06:48:48 EDT 2000
I've been trying to get an IE WebBrowser control to report OnScroll events
to my (wxPython wxWindow) class. I've got the control created, and I can
catch the WebBrowser events as expected. However, I can't seem to convince
the COM system that my callback is usable.
Here's what I'm trying (added to wxPython's IE demo):
def OnDownloadComplete(self ):
print 'download complete'
try:
class CallbackRedirect:
def __init__(self, object ):
self.object = object
def __call__( self, *args, **namedargs ):
return apply( self.object, args,
namedargs )
self.ie.Document.documentElement.attachEvent(
"onscroll", CallbackRedirect( self.OnScroll) )
download complete
Traceback (innermost last):
File "P:\portals\tests\iedemo.py", line 155, in OnDownloadComplete
self.ie.Document.documentElement.attachEvent( "onscroll",
CallbackRedirect(
self.OnScroll) )
File "<COMObject <unknown>>", line 2, in attachEvent
TypeError: The Python instance can not be converted to a COM object
Not really sure how to do this. The VB docs say to use ByRef( methodname)
to pass the argument, but I don't see a similar macro anywhere in the python
code. Just using the raw function gives:
download complete
Traceback (innermost last):
File "P:\portals\tests\iedemo.py", line 159, in OnDownloadComplete
self.ie.Document.documentElement.attachEvent( "onscroll", self.OnScroll
)
File "<COMObject <unknown>>", line 2, in attachEvent
ValueError: argument is not a COM object
Does pythoncom have some convention for creating callback objects to which
I'm not adhering?
Thoughts and suggestions welcome,
Mike
__________________________________
Mike C. Fletcher
Designer, VR Plumber
http://members.home.com/mcfletch
More information about the Python-list
mailing list