[python-win32] How to get win32com events .. in my main class?

Laurent Dufréchou Laurent.Dufrechou at free.fr
Tue Dec 6 14:39:47 CET 2005


Hello,

I'm currently trying to use event from a win32 application using it's
COM interface.

To connect to the application I use:

#main class
class MyApp_InterfaceManager (Thread):
  ...
  def run (self):
    # First we initialize the COM libraries for current thread
    pythoncom.CoInitialize()
    #Then we connect to the app with event handling...
    self.app = DispatchWithEvents('MyApp',MyApp_AppEvents)

#event class
class MyApp_AppEvents:
  OnHalt:
    print "halt event..."

>From here all is ok when the OnHalt event arrives the print is called.
The problem I have is that I need that MyApp_AppEvents class knows the
thread object to call a thread function when the event occurs(for
example I need to toggle a flag)

I've got no idea how to do that, as th event handler object is not
member of the main class...
Anyone has encoutered the problem?
I've tryied to use getevents but with no result...


Best regards,

Laurent


More information about the Python-win32 mailing list