ch3_11.py
from tkinter import *
window = Tk()
window.title("ch3_11")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow") # 设置标签宽度15
lab2 = Label(window,text="2长庚大学",
bg="lightgreen") #
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue") #
lab1.pack() #
lab2.pack(ipadx=10) #
lab3.pack(ipady=10) #
window.mainloop()
ch3_12.py
from tkinter import *
root = Tk()
root.title("ch3_12")
root.geometry("300x180")
oklabel=Label(root,text="OK",
font="Times 20 bold",
fg="white",bg="blue")
oklabel.pack(anchor=S,side=RIGHT,padx=10,pady=10)
root.mainloop()
ch3_13.py
from tkinter import *
root = Tk()
root.title("ch3_13")
root.geometry("300x180")
oklabel=Label(root,text="OK",
font="Times 20 bold",
fg="white",bg="blue")
oklabel.pack(anchor=S,side=RIGHT,padx=10,pady=10)
nolabel=Label(root,text="NO",
font="Times 20 bold",
fg="white",bg="red")
nolabel.pack(anchor=S,side=RIGHT,pady=10)
root.mainloop()
ch3_14.py
from tkinter import *
window = Tk()
window.title("ch3_14")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(fill=X)
lab2.pack() # lab2.pack(fill=Y) #
lab3.pack(fill=X)
window.mainloop()
ch3_15.py
from tkinter import *
window = Tk()
window.title("ch3_14")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(fill=X)
lab2.pack(fill=Y) # lab2.pack() #
lab3.pack(fill=X)
window.mainloop()
ch3_16.py
from tkinter import *
window = Tk()
window.title("ch3_14")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(side=LEFT)
lab2.pack()
lab3.pack()
window.mainloop()
ch3_17.py
from tkinter import *
window = Tk()
window.title("ch3_17")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(side=LEFT,fill=Y)
lab2.pack(fill=X)
lab3.pack()
window.mainloop()
ch3_18.py
from tkinter import *
window = Tk()
window.title("ch3_18")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(side=LEFT,fill=Y)
lab2.pack(fill=X)
lab3.pack(fill=X)
window.mainloop()
ch3_19.py
from tkinter import *
window = Tk()
window.title("ch3_19")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(side=LEFT,fill=Y)
lab2.pack(fill=X)
lab3.pack(fill=BOTH) # 这里没有效果,BOTH不起作用
window.mainloop()
ch3_20.py
from tkinter import *
window = Tk()
window.title("ch3_19")
lab1 = Label(window,text="1明志科技大学",
bg="lightyellow")
lab2 = Label(window,text="2长庚大学",
bg="lightgreen")
lab3 = Label(window,text="3长庚科技大学",
bg="lightblue")
lab1.pack(side=LEFT,fill=Y)
lab2.pack(fill=X)
lab3.pack(fill=BOTH,expand=True) # 这里没有效果,BOTH不起作用
window.mainloop()