Fixed variable configuring for CTkOptionMennu

This commit is contained in:
Tom Schimansky 2022-09-17 13:39:22 +02:00
parent 89fa0a8758
commit dab93a6a5e
2 changed files with 4 additions and 2 deletions

View File

@ -226,7 +226,8 @@ class CTkOptionMenu(CTkBaseClass):
if self.variable is not None and self.variable != "":
self.variable_callback_name = self.variable.trace_add("write", self.variable_callback)
self.set(self.variable.get(), block_set_variable=True)
self.current_value = self.variable.get()
self.text_label.configure(text=self.current_value)
else:
self.variable = None

View File

@ -78,8 +78,9 @@ switch_2 = customtkinter.CTkSwitch(master=app, variable=s_var, textvariable=s_va
switch_2.pack(pady=20, padx=10)
optionmenu_var = tkinter.StringVar(value="test")
optionmenu_1 = customtkinter.CTkOptionMenu(master=app, variable=optionmenu_var, values=["Option 1", "Option 2", "Option 3"])
optionmenu_1 = customtkinter.CTkOptionMenu(master=app, variable=None, values=["Option 1", "Option 2", "Option 3"])
optionmenu_1.pack(pady=20, padx=10)
optionmenu_1.configure(variable=optionmenu_var)
combobox_1 = customtkinter.CTkComboBox(master=app, values=["Option 1", "Option 2", "Option 3"])
combobox_1.pack(pady=20, padx=10)
combobox_1.configure(variable=optionmenu_var)