Skip to main content

CTkOptionMenu

Example Code

Without variable:

def optionmenu_callback(choice):
print("optionmenu dropdown clicked:", choice)

optionmenu = customtkinter.CTkOptionMenu(app, values=["option 1", "option 2"],
command=optionmenu_callback)
optionmenu.set("option 2")

With variable:

def optionmenu_callback(choice):
print("optionmenu dropdown clicked:", choice)

optionmenu_var = customtkinter.StringVar(value="option 2")
optionmenu = customtkinter.CTkOptionMenu(app,values=["option 1", "option 2"],
command=optionmenu_callback,
variable=optionmenu_var)

Arguments

argumentvalue
masterroot, frame, top-level
widthbox width in px
heightbox height in px
corner_radiuscorner radius in px
fg_colorforeground (inside) color, tuple: (light_color, dark_color) or single color
button_colorright button color, tuple: (light_color, dark_color) or single color
button_hover_colorhover color, tuple: (light_color, dark_color) or single color
dropdown_fg_colordropdown fg color, tuple: (light_color, dark_color) or single color
dropdown_hover_colordropdown button hover color, tuple: (light_color, dark_color) or single color
dropdown_text_colordropdown text 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
fontbutton text font, tuple: (font_name, size)
dropdown_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 dropdown is clicked manually
variableStringVar to control or get the current text
valueslist of strings with values that appear in the option menu dropdown
dynamic_resizingenable/disable automatic resizing of optionmenu when text is too big to fit: True (standard), False
anchor"n", "s", "e", "w", "center", orientation of the text inside the optionmenu, default is "w"

Methods

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

    All attributes can be configured and updated.

    optionmenu.configure(values=["new value 1", "new value 2"])
  • .cget(attribute_name)

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

    state = optionmenu.cget("state")
  • .set(value)

    Set optionmenu to specific string value. Value don't has to be part of the values list.

  • .get()

    Get current string value of optionmenu.