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?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值