[python-win32] How to work with Dispach callback?

Mark Hammond mhammond at skippinet.com.au
Tue Feb 12 13:24:36 CET 2008


I'd suggest passing 'useDispatcher=1' to com_wrap, so that debug output is
generated as your object is called (you can see it via the win32traceutil.py
tool).  Its hard to tell though, as the MicroStation object is throwing a
type error without providing any other information about what it is upset
about.  You might want to check that MicroStation supports IDispatch based
event interfaces, otherwise you will need yet more magic to make things
work...

Cheers,

Mark

> -----Original Message-----
> From: python-win32-bounces at python.org [mailto:python-win32-
> bounces at python.org] On Behalf Of Alexandr N Zamaraev
> Sent: Tuesday, 12 February 2008 5:41 PM
> To: python-win32 at python.org
> Subject: Re: [python-win32] How to work with Dispach callback?
> 
> Alexandr N Zamaraev wrote:
> > I use MicroStation through Automation interface.
> > But I do not known how use Events.
> I change code:
> <code>
> class LocateCommandEvents(object):
>     _com_interfaces_ = [IID_ILocateCommandEvents]
> 
>     _public_methods_ = []
>     _dispid_to_func_ = {
>       0x60020000: 'Accept', 0x60020001: 'LocateFailed', 0x60020002:
> 'LocateFilter', 0x60020003: 'LocateReset', 0x60020004: 'Cleanup',
> 0x60020005: 'Start', 0x60020006: 'Dynamics'}
>      # skip dummy methods...
> 
> events = LocateCommandEvents()
> ev = com_wrap(events, usePolicy=EventHandlerPolicy)
> MSApp.CommandState.StartLocate(ev)
> </code>
> But it not work:
>     File
> "D:\Lang\Projects\Promsoft\mun_ob\doc_circ\src\tools\MicroEvents.py",
> line 220, in start_event
>       MSApp.CommandState.StartLocate(ev)
>     File
> "C:\Lang\Python\25\lib\site-packages\win32com\gen_py\CF9F97BF-39F2-
> 4B8E-835C-8BE9E99DAF5Bx0x8x0.py",
> 
> 
> line 8047, in StartLocate
>       return self._oleobj_.InvokeTypes(1610743809, LCID, 1, (24, 0),
> ((9,
> 1),),EventHandlers
> pywintypes.com_error: (-2147352571, 'Discrepancy of types.', None, 1)
> 
> 
> _______________________________________________
> python-win32 mailing list
> python-win32 at python.org
> http://mail.python.org/mailman/listinfo/python-win32



More information about the python-win32 mailing list