# ch3_21.py
from tkinter import *
root = Tk()
root.title("ch3_21") # 視窗標題
root.geometry("300x200")
Label(root,text='Mississippi',bg='red',fg='white',
font='Times 24 bold').pack(fill=X)
Label(root,text='Kentucky',bg='green',fg='white',
font='Arial 24 bold italic').pack(fill=BOTH,expand=True)
Label(root,text='Purdue',bg='blue',fg='white',
font='Times 24 bold').pack(fill=X)
root.mainloop()
# ch3_22.py
from tkinter import *
root = Tk()
root.title("ch3_22") # 視窗標題
Label(root,text='Mississippi',bg='red',fg='white',
font='Times 20 bold').pack(side=LEFT,fill=Y)
Label(root,text='Kentucky',bg='green',fg='white',
font='Arial 20 bold italic').pack(side=LEFT,fill=BOTH,expand=True)
Label(root,text='Purdue',bg='blue',fg='white',
font='Times 20 bold').pack(side=LEFT,fill=Y)
root.mainloop()
# ch3_23.py
from tkinter import *
root = Tk()
root.title("ch3_23")
root.geometry("300x180") # 設定視窗勘寬300高180
print("執行前",root.pack_slaves())
oklabel=Label(root,text="OK", # 標籤內容是OK
font="Times 20 bold", # Times字型20粗體
fg="white",bg="blue") # 藍底白字
oklabel.pack(anchor=S,side=RIGHT, # 從右開始在南方配置
padx=10,pady=10) # x和y軸間距皆是10
nolabel=Label(root,text="NO", # 標籤內容是OK
font="Times 20 bold", # Times字型20粗體
fg="white",bg="red") # 藍底白字
nolabel.pack(anchor=S,side=RIGHT, # 從右開始在南方配置
pady=10) # y軸間距皆是10
print("執行後",root.pack_slaves())
root.mainloop()
沒有留言:
張貼留言