Custom Tkinter OptionMenu not shown

80 Views Asked by At

Something is wrong with my CustomTkinter application, everything dissapears and if i remove this code it works but without my option menu. Can somebody say where i made a mistake?

choices = set()
for entry in df1["Cuisines"]:
    choices.update([cuisine.strip() for cuisine in entry.split(",")])
cuisine_choice = tk.StringVar()
optionmenu = ctk.CTkOptionMenu(choice_window, cuisine_choice, *choices)
optionmenu.pack()
cuisine_choice.set("North Indian")

I need this option menu to be shown in my tkinter app

1

There are 1 best solutions below

0
On

Note that the arguments required for CTkOptionMenu(...) is not the same as tkinter OptionMenu(...), the line optionmenu = ctk.CTkOptionMenu(choice_window, cuisine_choice, *choices) should raise exception.

Use below instead:

optionmenu = ctk.CTkOptionMenu(choice_window, variable=cuisine_choice, values=list(choices))

See the official document on CTkOptionMenu.