python之GUI图形界面

来源:互联网 发布:linux安全加固手册 编辑:程序博客网 时间:2024/06/06 04:02

先上例子:

from Tkinter import *  def on_click():      label['text'] = text.get()    root = Tk(className='bitunion')  label = Label(root)  label['text'] = 'be on your own'  label.pack()  text = StringVar()  text.set('change to what?')  entry = Entry(root)  entry['textvariable'] = text  entry.pack()  button = Button(root)  button['text'] = 'change it'  button['command'] = on_click  button.pack()  root.mainloop() 


运行结果:可以在文本框里面输入文本,当点击“change it”按钮时,最上方会显示文本框中的内容



其他资料:

python GUI例子:http://www.cnblogs.com/monsteryang/p/6558904.html
python GUI编程:https://zhuanlan.zhihu.com/p/22619896?refer=passer