CTkSlider
Example Code
def slider_event(value):
print(value)
slider = customtkinter.CTkSlider(app, from_=0, to=100, command=slider_event)
Changed in 6.0
The slider can now be moved with the mouse wheel. Use scroll_step to set how far one wheel step moves it.
Arguments
| argument | value |
|---|---|
| master | root, tkinter.Frame or CTkFrame |
| command | callback function, receives slider value as argument |
| variable | tkinter.IntVar or tkinter.DoubleVar object |
| width | slider width in px |
| height | slider height in px |
| corner_radius | corner radius of the slider bar in px |
| button_corner_radius | corner radius of the slider button in px |
| border_width | space around the slider rail in px |
| button_length | length of the slider button in px, 0 makes it round |
| from_ | lower slider value |
| to | upper slider value |
| number_of_steps | number of steps in which the slider can be positioned |
| scroll_step | value change per mouse wheel step, default is 1/20 of the range or one step if number_of_steps is set (new in 6.0) |
| bg_color | color behind the widget, only visible at the rounded corners, "transparent" (default) takes the color of the parent widget, tuple: (light_color, dark_color) or single color |
| fg_color | foreground color, tuple: (light_color, dark_color) or single color |
| progress_color | tuple: (light_color, dark_color) or single color or "transparent", color of the slider line before the button |
| border_color | slider border color, tuple: (light_color, dark_color) or single color or "transparent", default is "transparent" |
| button_color | color of the slider button, tuple: (light_color, dark_color) or single color |
| button_hover_color | hover color, tuple: (light_color, dark_color) or single color |
| orientation | "horizontal" (standard) or "vertical" |
| state | "normal" or "disabled" (not clickable) |
| hover | bool, enable/disable hover effect, default is True |
Arguments and methods that all widgets share, like bg_color, .bind(), .focus() or .destroy(), are described on Common arguments and methods.
Methods
-
.configure(attribute=value, ...)
All attributes can be configured and updated, for example:
slider.configure(number_of_steps=25) -
.cget(attribute_name)
Pass attribute name as string and get current value of attribute.
-
.set(value)
Set slider to specific value.
-
.get()
Get current value of slider.
value = slider.get()