How to use the callback of COM objects

Gillou nospam at bigfoot.com
Wed Oct 3 18:44:27 CEST 2001


Thanks a lot Dale,

It semms to give some good results

--Gilles

"Dale Strickland-Clark" <dale at riverhall.NOSPAMco.uk> a écrit dans le message
news: tt9mrtc1kd8hmfda4a25lcu0r3atlv3p23 at 4ax.com...
> "Gillou" <nospam at bigfoot.com> wrote:
>
> >Hi,
> >
> >I've tried this to provide a callback function to a COM object:
> >==============
> >import win32com.client
> >def HandleReadyState():
> >    # anything you want
> >    return
> >ox = win32com.client.Dispatch('MSXML.DomDocument')
> >ox.onreadystatechange = HandleReadyState
> >==============
> >And the last line raises this:
> >==============
> >Traceback (most recent call last):
> >  File "validation.py", line 7, in ?
> >    ox.onreadystatechange = HandleReadyState
> >  File "C:\Python21\win32com\client\dynamic.py", line 467, in __setattr__
> >    self._oleobj_.Invoke(self._olerepr_.propMapPut[attr].dispid, 0,
> >pythoncom.DI
> >SPATCH_PROPERTYPUT, 0, value)
> >TypeError: Objects of type 'function' can not be converted to a COM
VARIANT
> >=============
> >
> >This works perfectly when the equivalent is programmed in javascript.
> >"onreadystatechange" is an event that can be handled by a user function.
> >
> >Did I miss something ?
> >
> >Thanks in advance fo any hint.
> >
> >--Gilles
> >
> >
>
> There is DispatchWithEvents which might be what you're looking for but
> I've never tried to use it.
> --
> Dale Strickland-Clark
> Riverhall Systems Ltd





More information about the Python-list mailing list