# ch3_36.py
from tkinter import *
window = Tk()
window.title("ch3_36") # 視窗標題
lab1 = Label(window,text="明志科技大學",
bg="lightyellow", # 標籤背景是淺黃色
width=15) # 標籤寬度是15
lab2 = Label(window,text="長庚大學",
bg="lightgreen", # 標籤背景是淺綠色
width=15) # 標籤寬度是15
lab3 = Label(window,text="長庚科技大學",
bg="lightblue", # 標籤背景是淺藍色
width=15) # 標籤寬度是15
lab1.place(x=0,y=0) # 直接定位
lab2.place(x=30,y=50) # 直接定位
lab3.place(x=60,y=100) # 直接定位
window.mainloop()
# ch3_37.py
from tkinter import *
root = Tk()
root.title("ch3_37")
root.geometry("640x480")
night = PhotoImage(file="night.png") # 影像night
lab1 = Label(root,image=night)
lab1.place(x=20,y=30,width=200,height=120)
snow = PhotoImage(file="snow.png") # 影像snow
lab2 = Label(root,image=snow)
lab2.place(x=200,y=200,width=400,height=240)
root.mainloop()
# ch3_38.py
from tkinter import *
root = Tk()
root.title("ch3_38")
root.geometry("640x480")
night = PhotoImage(file="night.png")
label=Label(root,image=night)
label.place(relx=0.1,rely=0.1,relwidth=0.8,relheight=0.8)
root.mainloop()
# ch3_39.py
from tkinter import *
root = Tk()
root.title("ch3_39")
root.geometry("640x480")
night = PhotoImage(file="night.png")
label=Label(root,image=night)
label.place(relx=0.1,rely=0.1,relheight=0.8)
root.mainloop()
沒有留言:
張貼留言