-
Notifications
You must be signed in to change notification settings - Fork 1.1k
CTkScrollableFrame
Tom Schimansky edited this page Feb 6, 2023
·
8 revisions
Standard scrollable frame with vertical orientation:
scrollable_frame = customtkinter.CTkScrollableFrame(master=root_tk, width=200, height=200)
Scrollable frame structured into a class:
import customtkinter
class MyFrame(customtkinter.CTkScrollableFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
# add widgets onto the frame...
self.label = customtkinter.CTkLabel(self)
self.label.grid(row=0, column=0, padx=20)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.my_frame = MyFrame(master=self, width=300, height=200)
self.my_frame.grid(row=0, column=0, padx=20, pady=20)
app = App()
app.mainloop()
which results in:
The above example can be slightly modified, so that the scrollable frame completely fills the app window:
class MyFrame(customtkinter.CTkScrollableFrame):
def __init__(self, master, **kwargs):
super().__init__(master, **kwargs)
# add widgets onto the frame...
self.label = customtkinter.CTkLabel(self)
self.label.grid(row=0, column=0, padx=20)
class App(customtkinter.CTk):
def __init__(self):
super().__init__()
self.grid_rowconfigure(0, weight=1)
self.grid_columnconfigure(0, weight=1)
self.my_frame = MyFrame(master=self, width=300, height=200, corner_radius=0, fg_color="transparent")
self.my_frame.grid(row=0, column=0, sticky="nsew")
app = App()
app.mainloop()
which results in:
More examples can be found here: https://github.com/TomSchimansky/CustomTkinter/blob/master/examples/scrollable_frame_example.py
argument | value |
---|---|
master | root, Frame or Toplevel |
width | width in px (inner frame dimensions) |
height | height in px (inner frame dimensions) |
corner_radius | corner radius in px |
border_width | border width in px |
fg_color | foreground color, tuple: (light_color, dark_color) or single color or "transparent" |
border_color | border color, tuple: (light_color, dark_color) or single color |
scrollbar_fg_color | scrollbar foreground color, tuple: (light_color, dark_color) or single color |
scrollbar_button_color | scrollbar button color, tuple: (light_color, dark_color) or single color |
scrollbar_button_hover_color | scrollbar button hover color, tuple: (light_color, dark_color) or single color |
label_fg_color | label foreground color color, tuple: (light_color, dark_color) or single color |
label_text_color | label text color, tuple: (light_color, dark_color) or single color |
label_text | label text for label (title for frame) |
label_font | font for label, tupel font or CTkFont |
label_anchor | anchor for label, orientation of text, ("n", "ne", "e", "se", "s", "sw", "w", "nw", "center") |
orientation | scrolling direction, "vertical" (default), "horizontal" |
-
All attributes can be configured and updated.
-
Pass attribute name as string and get current value of attribute.
CustomTkinter by Tom Schimansky 2022
The Github Wiki is outdated, the new documentation can be found at: