Skip to content

CTkScrollbar

Tom Schimansky edited this page Dec 4, 2022 · 4 revisions

Example Code:

Default theme:

import customtkinter, tkinter

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

# create scrollable textbox
tk_textbox = tkinter.Text(app, highlightthickness=0)
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:

argument value
master root, tkinter.Frame or CTkFrame
command function of scrollable widget to call when scrollbar is moved
width button width in px
height button height in px
corner_radius corner radius in px
border_spacing foreground space around the scrollbar in px (border)
fg_color forground color, tuple: (light_color, dark_color) or single color or "transparent"
button_color scrollbar color, tuple: (light_color, dark_color) or single color
button_hover_color scrollbar hover color, tuple: (light_color, dark_color) or single color
minimum_pixel_length minimum length of scrollbar in px
orientation "vertical" (standard), "horizontal"
hover hover effect (True/False)

Methods:

scrollbar = CTkScrollbar(master)
scrollbar.configure(...)
value_1, value_2 = scrollbar.get()
scrollbar.set(value_1, value_2)

⚠️ Attention ⚠️

The Github Wiki is outdated, the new documentation can be found at:

https://customtkinter.tomschimansky.com

Clone this wiki locally