在上一篇随笔“用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文件
运行后效果:
IronPython的Hello World

相关文章:

  • 2021-04-04
  • 2021-09-01
  • 2021-05-27
  • 2021-09-21
  • 2021-05-09
猜你喜欢
  • 2021-06-06
  • 2021-04-18
  • 2021-12-26
  • 2021-10-08
  • 2021-10-25
  • 2021-08-28
相关资源
相似解决方案