返回列表 發帖

圖形介面 (三) - grid排版練習

  1. import tkinter as tk
  2. win=tk.Tk()
  3. win.title("主視窗")
  4. win.resizable(0,0)
  5. lb=tk.Label(win,bg="blue",text="1",font=("微軟正黑體",16),
  6.             width=10,height=3).grid(row=0,column=0,padx=10,pady=10)
  7. lb=tk.Label(win,bg="green",text="2",font=("微軟正黑體",16),
  8.             width=10,height=3).grid(row=0,column=1,padx=10,pady=10)
  9. lb=tk.Label(win,bg="red",text="3",font=("微軟正黑體",16),
  10.             width=10,height=3).grid(row=1,column=0,padx=10,pady=10)
  11. lb=tk.Label(win,bg="gray",text="4",font=("微軟正黑體",16),
  12.             width=10,height=3).grid(row=1,column=1,padx=10,pady=10)
  13. win.mainloop()
複製代碼

  1. import tkinter as tk
  2. win=tk.Tk()
  3. win.title("主視窗")
  4. win.resizable(0,0)
  5. lb=tk.Label(win,bg="blue",text="1",font=("微軟正黑體",20),width=10,height=3).grid(row=0,column=0,padx=10,pady=10)
  6. lb=tk.Label(win,bg="green",text="2",font=("微軟正黑體",20),width=10,height=3).grid(row=0,column=1,padx=10,pady=10)
  7. lb=tk.Label(win,bg="yellow",text="3",font=("微軟正黑體",20),width=10,height=3).grid(row=1,column=0,padx=10,pady=10)
  8. lb=tk.Label(win,bg="red",text="4",font=("微軟正黑體",20),width=10,height=3).grid(row=1,column=1,padx=10,pady=10)
  9. win.mainloop()
複製代碼

TOP

  1. import tkinter as tk
  2. win=tk.Tk()
  3. win.title("主視窗")
  4. win.resizable(0,0)
  5. lb=tk.Label(win,bg="blue",text="1",font=("微軟正黑體",16), width=10,height=3).grid(row=0,column=0, padx=10,pady=10)
  6. lb=tk.Label(win,bg="green",text="2",font=("微軟正黑體",16), width=10,height=3).grid(row=0,column=1, padx=10,pady=10)
  7. lb=tk.Label(win,bg="red",text="3",font=("微軟正黑體",16), width=10,height=3).grid(row=1,column=0, padx=10,pady=10)
  8. lb=tk.Label(win,bg="grey",text="4",font=("微軟正黑體",16), width=10,height=3).grid(row=1,column=1, padx=10,pady=10)
  9. win.mainloop()
複製代碼

TOP

返回列表