第三节课,老师让我们自学GUI编程,这是我在学习过程中记下的笔记(用的是python2.7)。
1.
eg1:
from Tkinter import * #导入Tkinter库,开头必须是大写
root=Tk() #创建窗口对象为空
w1=Label(root,text="我是来搞笑的啦",bg="yellow",width=15,height=4) #bg和background都可以,width,height都是lable的宽度和高度
w2=Label(root,text="我是来搞笑的啦",background="red",width=20,height=3)
w1.pack(side='bottom') #pack() 是布局,通常有side('top','bottom','left','right'默认是top)
w2.pack(fill=BOTH)