Hi all, I've got a python script that I want to create a C# GUI for. I'd like to have a web browser control on the form that I can control from python. This is not too difficult - just drop a WebBrowser control on the form and create a public property to expose the control. The problem is that .net is wrapping the control (AxHost etc) and not all the methods are exposed (e.g. Document.all.tags does not work...) Can I get the control's IDispatch and use late-binding? If so how???? If I cant can I create the activex control from python and 'place' it on a specific form (given a HWND)? Any examples of manually creating and placing a activeX control? Thanks for any advice. Andre
I've got a python script that I want to create a C# GUI for. I'd like to have a web browser control on the form that I can control from python. This is not too difficult - just drop a WebBrowser control on the form and create a public property to expose the control.
The problem is that .net is wrapping the control (AxHost etc) and not all the methods are exposed (e.g. Document.all.tags does not work...)
Can I get the control's IDispatch and use late-binding? If so how????
If I cant can I create the activex control from python and 'place' it on a specific form (given a HWND)? Any examples of manually creating and placing a activeX control?
Hi Andre - I'm not a real expert on interop stuff, but I'd suggest running aximp.exe or tlbimp.exe to generate a wrapper assembly from the dll that implements the WebBrowser control. The wrapper assembly should expose everything in a way that Python will be able to use it. Then you should be able to instantiate the control via the wrapper assembly from Python (or from C# for that matter), set it as your control property and drive it from Python. I'm guessing that VStudio.NET is using some kind of shortcut involving a RCW or something when you drop a control onto a form in the gui. Hope this helps! Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com
but I'd suggest running aximp.exe or tlbimp.exe
Thanks. This is done automatically by VStudio when importing an ActiveX control. I got around the problem by using the getElementByTag method, which is more w3c compliant anyway... I'm still having a problem though... When I create the form from python using reflection then the first time I access the web browser activeX control there is a long delay (approx 5 seconds). The exact same form does not have any delay when started from the EXE directly. The delay only occurs if I cast the 'browser.Document' object to a HTMLDocument *but* the delay occurs as soon as I call the method, i.e. before the cast. Yet if I take the cast out there is no delay. Very strange! I have included a sample app that demonstrated the problem. Clicking the button when the form is loaded from python will result in a delay before the first messagebox. Any ideas? Thanks
participants (2)
-
Andre Van Der Merwe
-
Brian Lloyd