Skip to main content

CTkScrollableFrame

Example Code

scrollable_frame = customtkinter.CTkScrollableFrame(app, width=200, height=200)

Structured into a class:

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()

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()

More examples can be found here: https://github.com/TomSchimansky/CustomTkinter/blob/master/examples/scrollable_frame_example.py

Arguments

argumentvalue
masterroot, Frame or Toplevel
widthwidth in px (inner frame dimensions)
heightheight in px (inner frame dimensions)
corner_radiuscorner radius in px
border_widthborder width in px
fg_colorforeground color, tuple: (light_color, dark_color) or single color or "transparent"
border_colorborder color, tuple: (light_color, dark_color) or single color
scrollbar_fg_colorscrollbar foreground color, tuple: (light_color, dark_color) or single color
scrollbar_button_colorscrollbar button color, tuple: (light_color, dark_color) or single color
scrollbar_button_hover_colorscrollbar button hover color, tuple: (light_color, dark_color) or single color
label_fg_colorlabel foreground color color, tuple: (light_color, dark_color) or single color
label_text_colorlabel text color, tuple: (light_color, dark_color) or single color
label_textlabel text for label (title for frame)
label_fontfont for label, tupel font or CTkFont
label_anchoranchor for label, orientation of text, ("n", "ne", "e", "se", "s", "sw", "w", "nw", "center")
orientationscrolling direction, "vertical" (default), "horizontal"

Methods

  • .configure(attribute=value, ...)

    All attributes can be configured.

  • .cget(attribute_name)

    Pass attribute name as string and get current value of attribute.