win32com: Setting ByRef parameters in an event

Mark Hammond MarkH at ActiveState.com
Thu Aug 16 19:32:46 EDT 2001


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.

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

>> (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.

Mark.




More information about the Python-list mailing list