I'm trying to make a language changer with the CTkOptionMenu but every time I open the "settings window" (the window where the options menu is located) it starts the function without any user clicking, and unlike the buttons putting "labmda: or lambda x:" didn't work
self.Optionmenu = customtkinter.CTkOptionMenu(self.window,
values=["Português-pt", "English"],
command=self.change_language,
hover=True)
self.Optionmenu.place(relx=0.95, rely=0.16, anchor="e")
def change_language(self, choice):
choice = self.Optionmenu.get()
match choice:
case "Português-pt":
Config.set("DEFAULTS", "Language", "Pt-pt")
with open(Config_File, "w") as f:
Config.write(f)
f.close
#case "Português-br":
# SelectedLanguage = L.PT_br
# root_tk.destroy()
# root_tk.__init__()
case "English":
Config.set("DEFAULTS", "Language", "English")
with open(Config_File, "w") as f:
Config.write(f)
f.close