test_ttk_frames.py 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. import tkinter
  2. import tkinter.ttk as ttk
  3. import customtkinter
  4. customtkinter.set_appearance_mode("light")
  5. app = customtkinter.CTk()
  6. app.geometry("1400x480")
  7. app.title("CustomTkinter TTk Compatibility Test")
  8. app.grid_rowconfigure(0, weight=1)
  9. app.grid_columnconfigure((0, 1, 2, 3, 5, 6), weight=1)
  10. button_0 = customtkinter.CTkButton(app)
  11. button_0.grid(padx=20, pady=20, row=0, column=0)
  12. frame_1 = tkinter.Frame(master=app)
  13. frame_1.grid(padx=20, pady=20, row=0, column=1, sticky="nsew")
  14. button_1 = customtkinter.CTkButton(frame_1, text="tkinter.Frame")
  15. button_1.pack(pady=20, padx=20)
  16. frame_2 = tkinter.LabelFrame(master=app, text="Tkinter LabelFrame")
  17. frame_2.grid(padx=20, pady=20, row=0, column=2, sticky="nsew")
  18. button_2 = customtkinter.CTkButton(frame_2, text="tkinter.LabelFrame")
  19. button_2.pack(pady=20, padx=20)
  20. frame_3 = customtkinter.CTkFrame(master=app)
  21. frame_3.grid(padx=20, pady=20, row=0, column=3, sticky="nsew")
  22. label_3 = customtkinter.CTkLabel(master=frame_3, text="CTkFrame Label", fg_color=("gray95", "gray15"))
  23. label_3.grid(row=0, column=0, columnspan=1, padx=5, pady=5, sticky="ew")
  24. button_3 = customtkinter.CTkButton(frame_3, text="CTkFrame")
  25. button_3.grid(row=1, column=0, padx=20)
  26. frame_3.grid_rowconfigure(1, weight=1)
  27. frame_3.grid_columnconfigure((0, ), weight=1)
  28. frame_4 = ttk.Frame(master=app)
  29. frame_4.grid(padx=20, pady=20, row=0, column=4, sticky="nsew")
  30. button_4 = customtkinter.CTkButton(frame_4, text="ttk.Frame")
  31. button_4.pack(pady=20, padx=20)
  32. frame_5 = ttk.LabelFrame(master=app, text="TTk LabelFrame")
  33. frame_5.grid(padx=20, pady=20, row=0, column=5, sticky="nsew")
  34. button_5 = customtkinter.CTkButton(frame_5)
  35. button_5.pack(pady=20, padx=20)
  36. frame_6 = ttk.Notebook(master=app)
  37. frame_6.grid(padx=20, pady=20, row=0, column=6, sticky="nsew")
  38. button_6 = customtkinter.CTkButton(frame_6, text="ttk.Notebook")
  39. button_6.pack(pady=20, padx=20)
  40. ttk_style = ttk.Style()
  41. ttk_style.configure(frame_3.winfo_class(), background='red')
  42. app.mainloop()