Howdy folks,
I'm getting outfoxed by a pesky ActiveX control that keeps bombing out
with a 'Catastrophic failure' as soon as I try and interact with it:
>>> from win32com.client import *
>>> d = Dispatch('TWS.TwsCtrl.1')
>>> d
<win32com.gen_py.Tws ActiveX Control module._DTws instance at 0x43406520>
>>> d.connect('', 7496, 0)
<snip>
pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)
>>> import tws
>>> de = DispatchWithEvents('TWS.TwsCtrl.1', tws.TwsEvents)
>>> de
<win32com.client.COMEventClass instance at 0x71273368>
>>> de.connect('', 7496, 0)
<snip>
pywintypes.com_error: (-2147418113, 'Catastrophic failure', None, None)
I came across [1], which notes that 'Catastrophic failure' upon first
invoking an ActiveX method is a good indication that the component needs
an event loop. It goes on to suggest some wx.activex-fu along the lines of:
>>> import wx, wx.activex
>>> app = wx.PySimpleApp()
>>> f = wx.Frame(None, -1, "")
>>> clsid = wx.activex.CLSID('TWS.TwsCtrl.1')
*** axw = wx.activex.ActiveXWindows(f, clsid)
>>> wx.activex.GernerateAXModule(axw, 'Tws', '.', verbose=True)
Unfortunately, if I run that code, it causes python.exe to crash at the
*** line above. I've never tried to interface with an ActiveX module
that requires an event-loop before, so I'm out of my COM-comfort zone.
FWIW, if you drop the OCX onto a VB form, it works fine. However,
trying to programmatically interact with the component with, say,
VBScript or Perl's Win32::OLE yields the same 'Catastrophic failure'
result I'm getting with Python.
Relevant files are available here:
http://wind.teleri.net/~trent/tws.zip
Shipped with the module:
Tws_i.h
Tws.idl
Tws.ocx
ComPropAccessor.h
Files I've added:
tws.py
The tws.py is simply the output of makepy, with an additional TwsEvents
class that I added in order to try DispatchWithEvents().
Any assistance would be appreciated.
Regards,
Trent.
[1]: http://www.wiredfool.com/2006/11/18/python-and-com-components/
_______________________________________________
python-win32 mailing list
python-win32@python.org
http://mail.python.org/mailman/listinfo/python-win32