[python-win32] I'm getting outfoxed by an ActiveX control...
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
Re: [python-win32] I'm getting outfoxed by an ActiveX control...
Trent Nelson wrote: 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) 8000. That's basically an error that says something bad happened, but we're not sure what it was. Also called anyone get the license number of that truck that hit me? 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) That doesn't run an event loop. It might set up a message queue, but in order to run an event loop and cause window messages to be dispatched, you have to call app.MainLoop(). Is this a GUI component? It's difficult for me to tell. If it is a GUI component, then you can't just instantiate it in empty space. You have to host it inside some GUI application. I see that it is a socket-based component. If they are using asynchronous socket processing, that also requires that the event loop be actively dispatching. If this expects to be part of a GUI application, then you are going to need to write a GUI application for it. -- Tim Roberts, t...@probo.com Providenza Boekelheide, Inc. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32
Re: [python-win32] I'm getting outfoxed by an ActiveX control...
On 23-Jul-10 2:29 PM, Tim Roberts wrote: Trent Nelson wrote: 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) That doesn't run an event loop. It might set up a message queue, but in order to run an event loop and cause window messages to be dispatched, you have to call app.MainLoop(). Yeah, unfortunately, I can't get far enough to call app.MainLoop() -- that wx.activex.ActiveXWindows(f, clsid) line crashes python.exe. Is this a GUI component? That's what's annoying -- it shouldn't be (the API is data-driven, it doesn't expose any UI controls), but it looks like it's been written as an ActiveX GUI component anyway. (I think the target audience for the ActiveX component is VB developers, so the developer use case they're targeting is drag tws.ocx onto your form.) They provide C++ and Java socket-oriented interfaces as well, so I'll have a play around with those instead. Thanks for confirming my suspicions. Regards, Trent. ___ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32