The Last Day Of Summer

.NET技术 C# ASP.net ActiveReport SICP 代码生成 报表应用 RDLC
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

IronPython的Hello World

Posted on 2004-08-27 15:08  Cure  阅读(1679)  评论(2编辑  收藏  举报

在上一篇随笔“用Ironpython写winform程序”里,写了一个显示窗体,这篇在此基础上添加了一个按钮,点击弹出对话框

用NotePad写一个文本文件,内容:

#导入名空间
from System.Windows.Forms import *
from System.Drawing import *

#窗体
f = Form()
f.Text = "Python Hello World"
#按钮
b = Button()
b.Text = "Click Me"

f.Controls.Add(b)

#定义按钮的事件
def buttonClick(data,event):
    MessageBox.Show("Hello World!!")
 
b.Click += buttonClick
f.ShowDialog()


另存或改为py后缀,这里存成test.py文件
运行后效果: