X-Received: by 10.224.17.140 with SMTP id s12mr3616285qaa.3.1361962150198; Wed, 27 Feb 2013 02:49:10 -0800 (PST) X-Received: by 10.49.85.35 with SMTP id e3mr47423qez.7.1361962150167; Wed, 27 Feb 2013 02:49:10 -0800 (PST) Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!npeer03.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!dd2no3471309qab.0!news-out.google.com!y6ni90qaj.0!nntp.google.com!t2no5371012qal.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.python Date: Wed, 27 Feb 2013 02:49:10 -0800 (PST) Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=89.143.244.106; posting-account=GfPZwQoAAAA6FR6Im2W2_YTmjxW3lSuK NNTP-Posting-Host: 89.143.244.106 User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <52692a42-6cdb-4c19-9f56-7fa2f313b7c4@googlegroups.com> Subject: win32com how to catch events From: igorjan2332@gmail.com Injection-Date: Wed, 27 Feb 2013 10:49:10 +0000 Content-Type: text/plain; charset=ISO-8859-1 X-Received-Bytes: 1727 Xref: csiph.com comp.lang.python:40047 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?