您的位置:首页 > 编程语言 > Python开发

python_界面编程

2011-11-29 14:44 190 查看


代码:
import Tkinter
top = Tkinter.Tk() 
label = Tkinter.Label(top, text='hello wrold' )
label.pack()  #管理和显示组件
Tkinter.mainloop()



import Tkinter
#按钮的使用
top = Tkinter.Tk()
button = Tkinter.Button(top, text='exit', command=top.quit)
button.pack()
Tkinter.mainloop()



import Tkinter
#按扭和标签的使用
top = Tkinter.Tk()
label = Tkinter.Label(top, text='hello,world')
label.pack()

button = Tkinter.Button(top, text='exit', command=top.quit, bg='red', fg='white')
button.pack(fill=Tkinter.X, expand=1)

Tkinter.mainloop()

#用标签控制字体大小
import Tkinter
def resize(ev=None):
label.config(font='Helvetica -%d bold' % \
scale.get())

top = Tkinter.Tk()
top.geometry('250x150')

label = Tkinter.Label(top, text='hello,world',\
font='Helvetica -12 bold')
label.pack(fill=Tkinter.Y, expand=1)

scale = Tkinter.Scale(top, from_=10, to=40,\
orient=Tkinter.HORIZONTAL, command=resize)
scale.set(12)
scale.pack(fill=Tkinter.X, expand=1)

top.mainloop()



























内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: