[IronPython] Guru question: Events as a method for invoking Python from C#?
dinov at exchange.microsoft.com
Thu Dec 21 21:43:32 CET 2006
This sounds reasonable. Another approach might be to implement IReflect in the interceptor class and then use the Ops.* functions (GetAttr, GetAttrNames, etc...) in order to expose the dynamic types out to COM dynamically - but that's considerably more work :)
If you don't want to use events you could have the interceptor class & a proxy class. You'd derive from the proxy class and override a bunch of virtual methods that the interceptor would call.
But basically it should work.
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Gutfreund, Yechezkal [ygutfreund at draper.com]
Sent: Thursday, December 21, 2006 7:51 AM
To: users at lists.ironpython.com
Subject: [IronPython] Guru question: Events as a method for invoking Python from C#?
I am embedding Microsoft Virtual Earth into a WPF project that uses python as the scripting language.
VE must run as a webcontrol.
Tasks that I have completed:
1. Creating the XAML wrapper
2. Embed the WebControl object in the XAML
3. loading XAML with the Avalon module from the Python tutorials
4. Using .InvokeScript() to call Jscript routines inside the web control and having VirtualEarth respond
What I am having trouble with is passing information back from VirtualEarth to Python.
the HTML object in JScript supports calling functions in the outer wrapper with:
If class that holds somefunction() is decorated with [Com(visible=true)] then all works. The issue is that Python classes and functions are not (and probably cannot) be made [Com(visible=true)] (they are need to be dynamically added and changed.
What I am considering is having a C# lib that Python loads that contains an "interceptor" class. This class would receive the calls from Jscript, packages them into events and then trigger the event so that python can receive them.
1) Do any IronPython or .NET gurus here see an show stoppers with this approach?
2) Are there any technical "gotcha's" I should look out for?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Ironpython-users