Possible Duplicate:
Instantiating a python class in C#
Embedding IronPython in C#
I trying this: link
C#:
private void Form1_Load(object sender, EventArgs e)
{
var ipy = Python.CreateRuntime();
dynamic test = ipy.UseFile(@"C:\Users\Admin\Desktop\Test.py");
textBox1.Text = test.Simple();
}
Python:
def Simple():
print "Hello from Python"
No error, when I run it, the textbox remain blank. What I doing wrong?
Your
Simplefunction does not return anything, it just prints output to console withprint. Something likereturn "Hello from Python"should give you results you want.Side note: you may be able to intercept console output, but it would probably not what you are interested in.