win32com how to catch events

Discussion in 'Python' started by igorjan2332@gmail.com, Feb 27, 2013.

  1. Guest

    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?
     
    , Feb 27, 2013
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Black
    Replies:
    8
    Views:
    4,161
    Xenos
    Aug 20, 2004
  2. Andrew Perella

    win32com visual studio dot net events

    Andrew Perella, Feb 11, 2004, in forum: Python
    Replies:
    0
    Views:
    354
    Andrew Perella
    Feb 11, 2004
  3. Adam
    Replies:
    9
    Views:
    577
    red floyd
    Feb 2, 2006
  4. Marteno Rodia

    catch doesn't catch a thrown exception

    Marteno Rodia, Aug 3, 2009, in forum: Java
    Replies:
    5
    Views:
    569
    Daniel Pitts
    Aug 5, 2009
  5. Chris

    Events Events Events Please Help

    Chris, Aug 30, 2005, in forum: ASP .Net Web Controls
    Replies:
    0
    Views:
    373
    Chris
    Aug 30, 2005
Loading...

Share This Page