How To Call IronPython functions in C#? -
i having problem in calling python functions in c# form. passed references. still python functions inaccessible. please me out.
using ironpython; using ironpython.hosting; using microsoft.scripting; using microsoft.scripting.hosting; using microsoft.scripting.utils; namespace converter { public partial class form1 : form { public form1() { initializecomponent(); m_scope = m_engine.createscope(); m_engine.executefile(@"c:\users\salman\desktop\lengthvolume.py"); m_engine.executefile(@"c:\users\salman\desktop\lengthvolume.py", m_scope); object lengthvolume =m_engine.operations.invoke(m_scope.getvariable("lengthvolume")); m_engine.operations.invokemember(lengthvolume, "f_i", new object[0]); action f_i2 = m_engine.operations.getmember<action>(lengthvolume, "f_i"); f_i2(); } private scriptengine m_engine = python.createengine(); private scriptscope m_scope = null; private void button21_click(object sender, eventargs e) { if (combobox9.selecteditem.equals("feet")) { if (combobox10.selecteditem.equals("inches")) { // python functions not accessible here } } }
python functions in python class
class lengthvolume(object): def f_i(self, a): return * 12 def f_k(self, a1): return a1 * 0.0003048
Comments
Post a Comment