返回列表 發帖
  1. import tkinter as tk

  2. win = tk.Tk()
  3. win.title("主視窗")
  4. win.resizable(0, 0)
  5. list1 = ["blue", "red", "green", "gray"]
  6. n = 1
  7. for i in range(4):
  8.     lb = tk.Label(win, bg=f"{list1[n-1]}", text=f"{n}", font=("微軟正黑體", 16),
  9.                   width=10, height=3).pack(padx=10, pady=10, side="left")
  10.     n += 1
  11.     i += 1
  12. win.mainloop()
複製代碼

TOP

返回列表