Hello,

I am trying to attach an event handler to a running pythoncom object.
The problem is I am not instantiating it via Dispatch. Basically I generated 
the python wrapper code (via makepy), and renamed it to a specific name, say, 
SignpadActivex.

The code is the following:
"""
import os, sys
import win32com
import SignpadActivex

class MyEvents():
    def OnPenDown(self):
        print 'evt pendown'
        self.m__signpad.SetEventEnableMask(7)
    
    def OnPenUp(self):
        print 'evt penup'
        self.m__signpad.SetEventEnableMask(7)
    
    def OnPenPoint(self):
        print 'pen point'
        self.m__signpad.SetEventEnableMask(7)

class SignPad():
    def __init__(self):
        self.m__signpad = None
    
    def createControl(self):
        self.m__signpad = TopazSigPlus.SigPlus()
        print dir(self.m__signpad)
        win32com.client.WithEvents(self.m__signpad, MyEvents)
        self.m__signpad.SetEventEnableMask(7)

if __name__ == '__main__':
    l__obj = None
    l__resp = raw_input('enter option ...:')
    while l__resp != 'x':
        if l__resp == 'c':
            l__obj = SignPad()
            l__obj.createControl()
        l__resp = raw_input('enter option ...:')
"""

Because I do instantiate this way, I dont have the DispatchWithEvents method. 
So I dont know how to add MyEvents event handler class managing the control's 
events.

>From the generated python code I got this:
"""
# This CoClass is known by the name 'SIGPLUS.SigPlusCtrl.1'
class SigPlus(CoClassBaseClass): # A CoClass
    # SigPlus Control
    CLSID = IID('{69A40DA3-4D42-11D0-86B0-0000C025864A}')
    coclass_sources = [
        _DSigPlusEvents,
    ]
    default_source = _DSigPlusEvents
    coclass_interfaces = [
        _DSigPlus,
    ]
    default_interface = _DSigPlus
"""

So basically how do I attach an event handler to that running object ?

Thank you !

                                          
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32

Reply via email to