test_scrollable_frame.py 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import customtkinter
  2. customtkinter.set_default_color_theme("dark-blue")
  3. app = customtkinter.CTk()
  4. app.grid_columnconfigure(2, weight=1)
  5. app.grid_rowconfigure(1, weight=1)
  6. toplevel = customtkinter.CTkToplevel()
  7. switch = customtkinter.CTkSwitch(toplevel, text="Mode", command=lambda: customtkinter.set_appearance_mode("dark" if switch.get() == 1 else "light"))
  8. switch.grid(row=0, column=0, padx=50, pady=50)
  9. frame_1 = customtkinter.CTkScrollableFrame(app, orientation="vertical", label_text="should not appear", fg_color="transparent")
  10. frame_1.grid(row=0, column=0, padx=20, pady=20)
  11. frame_1.configure(label_text=None)
  12. frame_2 = customtkinter.CTkScrollableFrame(app, orientation="vertical", label_text="CTkScrollableFrame")
  13. frame_2.grid(row=1, column=0, padx=20, pady=20)
  14. frame_3 = customtkinter.CTkScrollableFrame(app, orientation="horizontal")
  15. frame_3.grid(row=0, column=1, padx=20, pady=20)
  16. frame_4 = customtkinter.CTkScrollableFrame(app, orientation="horizontal", label_fg_color="transparent")
  17. frame_4.grid(row=1, column=1, padx=20, pady=20)
  18. frame_4.configure(label_text="CTkScrollableFrame")
  19. frame_5 = customtkinter.CTkScrollableFrame(app, orientation="vertical", label_text="CTkScrollableFrame", corner_radius=0)
  20. frame_5.grid(row=0, column=2, rowspan=2, sticky="nsew")
  21. for i in range(100):
  22. customtkinter.CTkCheckBox(frame_1).grid(row=i, padx=10, pady=10)
  23. customtkinter.CTkCheckBox(frame_2).grid(row=i, padx=10, pady=10)
  24. customtkinter.CTkCheckBox(frame_3).grid(row=0, column=i, padx=10, pady=10)
  25. customtkinter.CTkCheckBox(frame_4).grid(row=0, column=i, padx=10, pady=10)
  26. customtkinter.CTkCheckBox(frame_5).grid(row=i, padx=10, pady=10)
  27. app.mainloop()