本文介绍了如何打开与IronPython的现有窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想学习一些IronPython的或许要加快发展过程中的时间。我只是想通过端口一些简单的命令,目前我卡在打开现有的窗口。在C#中我会做这样的事情:
I'm trying to learn some IronPython to perhaps speed up the development process time. I'm just trying to port over some simple commands and currently I'm stuck on opening an existing window. In C# I would do something like:
var about = new AboutWin();
about.Show();
有谁知道如何去在IronPython中这样做呢?我敢肯定,这是可笑容易就像一切接缝与IronPython的。
Does anybody know how to go about doing this in IronPython? I'm sure it's ridiculously easy just like everything else seams to be with IronPython.
推荐答案
这应该做的伎俩:
import clr
clr.AddReference('PresentationFramework')
import System
from System.Windows.Markup import XamlReader
from System.Windows import Application
XAML_str = """<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="250" Height="100">
<TextBox Text="Hello from IronPython" />
</Window>"""
app = Application()
app.Run(XamlReader.Parse(XAML_str))
请参阅我的博客更大例子。
这篇关于如何打开与IronPython的现有窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!