python - 创建独立的可执行iron python 文件

标签 python visual-studio-2010 ironpython

我在 Visual Studio 中创建了一个 IronPython 项目,我希望它作为可执行文件运行

我尝试使用 pyc 创建可执行文件,但它不起作用(它绝对没有任何作用)。

ipy.exe Tools\Scripts\pyc.py /main:"C:\<Path>\WpfApplication1.py" /target:winexe

然后我创建了一个小示例项目来看看是否有效

WpfApplication1.py

    import wpf
    from System.Windows import Application, Window


    class MyWindow(Window):
         def __init__(self):
            wpf.LoadComponent(self, 'WpfApplication1.xaml')
            self.button.Content = 'My Button'
            self.textbox.Text = 'My Text'

        def Button_Click(self, sender, e):
            self.label.Content = self.textbox.Text


    if __name__ == '__main__':
        Application().Run(MyWindow())

和 xaml

    <Window 
   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
   Title="WpfApplication1" Height="300" Width="300"> 
   <Grid>
    <TextBox x:Name="textbox" Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" VerticalAlignment="Top" Width="120" />
    <Button x:Name="button" Content="Button" Height="23" HorizontalAlignment="Left" Margin="12,41,0,0" VerticalAlignment="Top" Width="75"  Click="Button_Click"/>
    <Label x:Name="label" Height="28" HorizontalAlignment="Left" Margin="47,117,0,0" VerticalAlignment="Top" Width="182" />
</Grid>

同样的问题,当我执行它时没有任何反应,我该如何调试?

最佳答案

    import clr
    clr.AddReference('IronPython.Wpf')

成功了

关于python - 创建独立的可执行iron python 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14726803/

相关文章:

c# - Visual Studio 单元测试生成错误

python - 带有 Visual C++ 编译器的 Cython?

python - 编写适用于 CPython、Jython 和 IronPython 的 Python 代码有哪些策略?

c# - IronPython 在创建实例时设置属性值(如 c#)

python - 如何使用 urlopen() 在 Python 中下载文件或向 urlretrieve() 添加自定义 header ?

python 内存问题

visual-studio-2010 - 是否可以将 Visual Studio Coded UI 测试作为测试代理部署到 Azure 或 EC2?

c# - C# 中的 IronPython 和 Nodebox

python - 更改 Pandas 数据框形状并将其展平

python - 如何抓取 html 中的非文本?