win32com how to catch events

I

igorjan2332

Hello,
I have a VBS sample code that I need to rewrite into python. It calls a com object which then generates events. My problem is that I don't know how to catch this events.
VBS sample looks like this:

Set oCOV = WScript.CreateObject( "RainbowObjectHandlerSrv.RainbowCOV", "oCOV_") ' like WithEvents in VB(A)

Sub oCOV_Update( ObjectId, ObjInstDataCOV)
'some code
End Sub

I tried like this:

from win32com.client import DispatchWithEvents
class Events:
def Update(self, ObjectID, Data):
print('update event')

oCOV = DispatchWithEvents("RainbowObjectHandlerSrv.RainbowCOV", Events)

my code can be found here: http://pastebin.com/EgfippzD
but the event newer gets called. Any idea what I'm doing wrong?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top