如何打开与IronPython的现有窗口窗口、IronPython

2023-09-06 05:49:28 作者:與鬼共粲

我想学习一些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))

请参阅我的博客更大例子。