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

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

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

  • .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.