[python-win32] How to code event handler for makepy generatedoutput?

Mark Hammond mhammond at skippinet.com.au
Sat Nov 6 01:23:40 CET 2004


> # If you create handlers, they should have the following prototypes:
> #	def OnTransfer(self, data=defaultNamedNotOptArg):
> #		"""method Transfer"""
>
>
> MY QUESTION IS THIS: how do I code a class that has the above method,
> and how do I pass an instance of that class to the automation
> server so
> that the automation server events are called on it?

The makepy generated code isn't actually used by event handlers - it is
there as a "prototype" for a class you write.  There is no need for your
class to derive from anything - just implement those methods.

As for the rest of the mechanics, check out the docsstrings and examples for
win32com.client.WithEvents and DispatchWithEvents

Mark



More information about the Python-win32 mailing list