用python写窗口程序的方法

小编给大家分享一下用python写窗口程序的方法,希望大家阅读完这篇文章后大所收获,下面让我们一起去探讨吧!

Python也可以创建界面,需要导入tkinter
具体看代码:

from tkinter import *

def btnClick():
    textLabel['text']='我点击了按钮'

root = Tk(className="我的第一个窗口程序");

textLabel = Label(root,text = '提示显示',justify=LEFT,padx=10)
textLabel.pack(side = TOP)

btn = Button(root)
btn['text']='点击测试'
btn['command'] = btnClick
btn.pack(side = BOTTOM)

mainloop()

用python写窗口程序的方法

看完了这篇文章,相信你对用python写窗口程序的方法有了一定的了解,想了解更多相关知识,欢迎关注行业资讯频道,感谢各位的阅读!