ironpython console怎么用_如何在表單中插入ironpython控制台?
I want to make a winform by C#, and add a ironpython console window in it, like a multiline textbox. So I can write python program into it to do some operations in my Winform software.
我想通過C#進行winform,並在其中添加一個ironpython控制臺窗口,就像多行文本框一樣。所以我可以在其中編寫python程序,在Winform軟件中進行一些操作。
How can I do that? Thanks.
我怎樣才能做到這一點?謝謝。
affixture:
附加物:
I created a opensource project IpyIF, Ironpython Interactive Window.http://ipyiw.codeplex.com/
我創建了一個開源項目IpyIF,Ironpython Interactive Window.http://ipyiw.codeplex.com/
2 個解決方案
#1
2
maybe you could start here.
也許你可以從這里開始。
Quickstart: You need a string with your code from your textbox in "script". Add references from IronPython, IronPython.Modules, Microsoft.Scripting and Microsoft.Scripting.Core to your project.
快速入門:您需要在“腳本”中使用文本框中的代碼創建一個字符串。將IronPython,IronPython.Modules,Microsoft.Scripting和Microsoft.Scripting.Core中的引用添加到項目中。
ScriptRuntime runtime = IronPython.Hosting.Python.CreateRuntime();
ScriptScope scope = runtime.GetEngine("py").CreateScope();
ScriptSource source = engine.CreateScriptSourceFromString(script,
Microsoft.Scripting.SourceCodeKind.Statements);
source.Execute(scope);
a real console is included in the CodePlex-Samples
CodePlex-Samples中包含一個真正的控制臺
#2
0
Thanks a lot. I got it by myself.
非常感謝。我自己得到了它。
I use two TextBox, one is to input code of ironpython, another is to redirect the ironpython output.
我使用兩個TextBox,一個是輸入ironpython的代碼,另一個是重定向ironpython輸出。
If someone want to know how to redirection, look this: How can I redirect the stdout of IronPython in C#?
如果有人想知道如何重定向,請看看:如何在C#中重定向IronPython的stdout?
總結
以上是生活随笔為你收集整理的ironpython console怎么用_如何在表單中插入ironpython控制台?的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: delphi listview 添加数据
- 下一篇: 楼梯计算机公式,各种楼梯面积的计算公式汇