Skip to main content

CTkScrollbar

Example Code

Create a CTkTextbox with external scrollbar:

app = customtkinter.CTk()
app.grid_rowconfigure(0, weight=1)
app.grid_columnconfigure(0, weight=1)

# create scrollable textbox
tk_textbox = customtkinter.CTkTextbox(app, activate_scrollbars=False)
tk_textbox.grid(row=0, column=0, sticky="nsew")

# create CTk scrollbar
ctk_textbox_scrollbar = customtkinter.CTkScrollbar(app, command=tk_textbox.yview)
ctk_textbox_scrollbar.grid(row=0, column=1, sticky="ns")

# connect textbox scroll event to CTk scrollbar
tk_textbox.configure(yscrollcommand=ctk_textbox_scrollbar.set)

app.mainloop()

Arguments

argumentvalue
masterroot, tkinter.Frame or CTkFrame
commandfunction of scrollable widget to call when scrollbar is moved
widthbutton width in px
heightbutton height in px
corner_radiuscorner radius in px
border_spacingforeground space around the scrollbar in px (border)
fg_colorforground color, tuple: (light_color, dark_color) or single color or "transparent"
button_colorscrollbar color, tuple: (light_color, dark_color) or single color
button_hover_colorscrollbar hover color, tuple: (light_color, dark_color) or single color
minimum_pixel_lengthminimum length of scrollbar in px
orientation"vertical" (standard), "horizontal"
hoverhover effect (True/False)

Methods

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

    All attributes can be configured.

  • .cget(attribute_name)

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

  • .get()

    Get current start and end value.

  • .set(start_value, end_value)

    Set start and end value.