python3.4 GUI

来源:互联网 发布:淘宝网店交易费用 编辑:程序博客网 时间:2024/06/06 04:28

python3.4中使用tkinter编写GUI界面程序,第一个例子,整体上来讲api为我们许多常用的默认属性,所以还是很好在这些基础上扩张我们的程序的

#!/usr/bin/env pythonimport tkinter as UI#回调函数def resize(ev = None):   label.config(font='Hello %d bold' % scale.get())top = UI.Tk()top.geometry('250x150')label = UI.Label(top,text='Hello World!',font='Helvetica -12 bold')label.pack(fill=UI.Y,expand=1)scale = UI.Scale(top,from_ =10,to = 40,orient = UI.HORIZONTAL,command=resize)scale.set(12)#绘画界面,fill=UI.X,expand=1表示可以被撑开scale.pack(fill=UI.X,expand=1)quit = UI.Button(top,text="QUIT",command=top.quit,activeforeground='white',activebackground='red')quit.pack()#消息循环UI.mainloop()

0 0
原创粉丝点击