[python-win32] Passing COM VB objects to Python COM servers
Craig Taverner
craig.taverner at comopt.com
Sun May 4 19:55:48 EDT 2003
Hi again,
I'm trying to pass a VB object to a Python COM object, that can then
call methods on the VB object. Although the Python code sees the object
as a PyIDispatch object, which I understand should allow me to call
public methods, no methods or properties are available. Here is some
example code:
VB
Dim interface As Object
Set interface = CreateObject("Python.RasterSourceX")
Dim cb As CallBack
Set cb = New CallBack
interface.StartCalculation cb
Python
def StartCalculation(self,callback):
self.vb_callback=callback.QueryInterface(pythoncom.IID_IDispatch)
self.vb_callback.Finished(25) # code throws exception here
The VB class "CallBack" has the public method "Finished" which currently
just takes an integer parameter. However, the python code seems unable
to access that method. The queryinterface(IDispatch) was added later,
based on some docs I read, but did nothing to help the situation. Print
statements, and the trace debugging, showed the object to already be an
PyIDispatch object. Is there something else I'm supposed to do to it to
get IDispatch to work? Perhaps the VB class is supposed to be defined in
some special way?
Thanks, Craig
More information about the Python-win32
mailing list