test_button_antialiasing.py 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import customtkinter
  2. customtkinter.set_default_color_theme("blue")
  3. customtkinter.set_appearance_mode("dark")
  4. app = customtkinter.CTk()
  5. app.geometry("600x1000")
  6. app.grid_columnconfigure(0, weight=1)
  7. app.grid_columnconfigure(1, weight=1)
  8. app.grid_columnconfigure(2, weight=1)
  9. app.grid_columnconfigure(3, weight=1)
  10. f1 = customtkinter.CTkFrame(app, fg_color="gray10", corner_radius=0)
  11. f1.grid(row=0, column=0, rowspan=1, columnspan=1, sticky="nsew")
  12. f1.grid_columnconfigure(0, weight=1)
  13. f2 = customtkinter.CTkFrame(app, fg_color="gray10", corner_radius=0)
  14. f2.grid(row=0, column=1, rowspan=1, columnspan=1, sticky="nsew")
  15. f2.grid_columnconfigure(0, weight=1)
  16. f3 = customtkinter.CTkFrame(app, fg_color="gray85", corner_radius=0)
  17. f3.grid(row=0, column=2, rowspan=1, columnspan=1, sticky="nsew")
  18. f3.grid_columnconfigure(0, weight=1)
  19. f4 = customtkinter.CTkFrame(app, fg_color="gray90", corner_radius=0)
  20. f4.grid(row=0, column=3, rowspan=1, columnspan=1, sticky="nsew")
  21. f4.grid_columnconfigure(0, weight=1)
  22. for i in range(0, 16, 1):
  23. b = customtkinter.CTkButton(f1, corner_radius=i, height=30, border_width=1, text=f"{i} {i-1}",
  24. border_color="white", fg_color=None, text_color="white")
  25. # b = tkinter.Button(f1, text=f"{i} {i-2}", width=20)
  26. b.grid(row=i, column=0, pady=5, padx=15, sticky="nsew")
  27. b = customtkinter.CTkButton(f2, corner_radius=i, height=30, border_width=0, text=f"{i}",
  28. fg_color="#228da8")
  29. b.grid(row=i, column=0, pady=5, padx=15, sticky="nsew")
  30. b = customtkinter.CTkButton(f3, corner_radius=i, height=30, border_width=1, text=f"{i} {i-1}",
  31. fg_color=None, border_color="gray20", text_color="black")
  32. b.grid(row=i, column=0, pady=5, padx=15, sticky="nsew")
  33. b = customtkinter.CTkButton(f4, corner_radius=i, height=30, border_width=0, text=f"{i}",
  34. border_color="gray10", fg_color="#228da8")
  35. b.grid(row=i, column=0, pady=5, padx=15, sticky="nsew")
  36. app.mainloop()