Skip to main content

CTkCheckBox

Example Code​

def checkbox_event():
print("checkbox toggled, current value:", check_var.get())

check_var = customtkinter.StringVar(value="on")
checkbox = customtkinter.CTkCheckBox(app, text="CTkCheckBox", command=checkbox_event,
variable=check_var, onvalue="on", offvalue="off")
CTkCheckBox example on macOS in dark mode

Arguments​

argumentvalue
masterroot, tkinter.Frame or CTkFrame
widthwidth of complete widget in px
heightheight of complete widget in px
checkbox_widthwidth of checkbox in px
checkbox_heightheight of checkbox in px
corner_radiuscorner radius in px
border_widthbox border width in px
bg_colorcolor 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_colorforeground (inside) color, tuple: (light_color, dark_color) or single color
border_colorborder color, tuple: (light_color, dark_color) or single color
hover_colorhover color, tuple: (light_color, dark_color) or single color
checkmark_colorcolor of the checkmark, tuple: (light_color, dark_color) or single color
text_colortext color, tuple: (light_color, dark_color) or single color
text_color_disabledtext color when disabled, tuple: (light_color, dark_color) or single color
textstring
textvariableTkinter StringVar to control the text
fontbutton text font, tuple: (font_name, size)
hoverenable/disable hover effect: True, False
statetkinter.NORMAL (standard) or tkinter.DISABLED (not clickable, darker color)
commandfunction will be called when the checkbox is clicked
variableTkinter variable to control or read checkbox state
onvaluestring or int for variable in checked state
offvaluestring or int for variable in unchecked state

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, for example

    checkbox.configure(state="disabled")
  • .cget(attribute_name)​

    Pass attribute name as string and get current value of attribute, for example.

    text = checkbox.cget("text")
  • .get()​

    Get current value, 1 or 0 (checked or not checked).

  • .set(state)​

    Set the checkbox to checked (True) or unchecked (False), the command will not be triggered. (new in 6.0)

  • .select()​

    Turn on checkbox (set value to 1), command will not be triggered.

  • .deselect()​

    Turn off checkbox (set value to 0), command will not be triggered.

  • .toggle()​

    Flip current value, command will be triggered.