Skip to main content

CTkRadioButton

Example Code

def radiobutton_event():
print("radiobutton toggled, current value:", radio_var.get())

radio_var = tkinter.IntVar(value=0)
radiobutton_1 = customtkinter.CTkRadioButton(app, text="CTkRadioButton 1",
command=radiobutton_event, variable= radio_var, value=1)
radiobutton_2 = customtkinter.CTkRadioButton(app, text="CTkRadioButton 2",
command=radiobutton_event, variable= radio_var, value=2)

Arguments

argumentvalue
masterroot, tkinter.Frame or CTkFrame
widthwidth of complete widget in px
heightheight of complete widget in px
radiobutton_widthwidth of radiobutton in px
radiobutton_heightheight of radiobutton in px
corner_radiuscorner radius in px
border_width_uncheckedborder width in unchecked state in px
border_width_checkedborder width in checked state 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
state"normal" (standard) or "disabled" (not clickable, darker color)
commandfunction will be called when the checkbox is clicked
variableTkinter variable to control or read checkbox state
valuestring or int value for variable when RadioButton is clicked

Methods

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

    All attributes can be configured and updated.

    radiobutton.configure(state="disabled")
  • .cget(attribute_name)

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

    state = radiobutton.cget("state")
  • .select()

    Select radio button (set value to 1), command will not be triggered.

  • .deselect()

    Deselect radio button (set value to 0), command will not be triggered.

  • .invoke()

    Same action as if user would click the radio button, command will be triggered.