win32com: Setting ByRef parameters in an event

Paul Moore paul.moore at uk.origin-it.com
Fri Aug 17 08:51:00 EDT 2001


On Fri, 17 Aug 2001 01:32:46 +0200, Mark Hammond <MarkH at ActiveState.com>
wrote:

>Paul Moore wrote:
>>>   import win32com.client
>>>
>>>   class wexEvents:
>>>       def OnTick(self, Remaining, WakeUp):
>>>           print "Tick...", Remaining
>>>           return -1
>>>
>>>   wex = win32com.client.DispatchWithEvents("WshToolbox.WScriptEx",
>>>                                            wexEvents)
>>>
>>>   wex.Sleep(10000,1000)
>>>
>>>But this doesn't seem to work! 
>
>It should :(  The Excel etc demos all work fine with very similar 
>constructs.  You could try:
>
>    return 1==1
>
>which due to an implementation detail will ensure that a VT_BOOL is 
>returned - however, this should not be necessary.

Nope, that din't fix it. Looks like it might be a bug in the component. But as
it works fine from VBScript and Perl (JavaScript can't handle ByRef
parameters, so I can't try that), I'm not sure how much chance I have of
getting the developer to care... :-(

>So no real clue I am afraid :(  If I could repro the error, I could 
>probably determine the problem.

I could send you the WScriptEx component. But it's executable-only, so you
can't see how the callback is implemented :-(

>>> (And, BTW, if I hit Ctrl-C, I get an error
>>>"Unhandled exception detected before entering Python." - shouldn't I >> get a KeybordInterrupt error?)
>
>Well, the Ctrl+C key is being hit _before_ Python code is entered.  In 
>this case we possibly do _not_ want Python to handle the exception - for 
>all we know, the object itself has handled the Ctrl+C key, and is 
>calling back into Python to handle it.

Ah, yes. I see what you mean. The Ctrl-C is being hit while the component has
control. Does this imply that the component isn't tidying up correctly after
Ctrl-C?

Thanks for the comments,
Paul.




More information about the Python-list mailing list