[python-win32] win32com and GetRef
Michael Thompson
spamtrap at day8.com.au
Thu Nov 3 00:47:01 CET 2005
I'm using win32com to manipulate the DOM inside of Internet
Explorer. Something like this:
#---------------------------------------------------------------------------
import win32com.client
ie = win32com.client.Dispatch('InternetExplorer.Application')
ie.Navigate('about:about')
body = ie.Document.getElementsByTagName("BODY")[0]
#
# Now comes the tricky part, I need to supply a "pointer-to-a-function"
#
def init():
pass
body.onload = init # XXXXXX Problem here
#---------------------------------------------------------------------------
Everything works a treat until the line marked XXXXXX. It fails with an exception:
TypeError: Objects of type 'function' can not be converted to a COM VARIANT
I'm need to effectively supply callback function for an event.
If I where using javascript, this line would be fine as is. If I was using VB,
then it would look like this:
body.onload = GetRef("init")
So, my question is how do I make the line marked XXXXX work in python? Is
it possible? Any pointers greatly appreciated.
Further Question: if its not possible would I be able to do this using Mozilla and pyxcom?
--
Mike
More information about the Python-win32
mailing list