From dab93a6a5e40228e61531ea84f0bddd5ee53784b Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 17 Sep 2022 13:39:22 +0200 Subject: [PATCH] Fixed variable configuring for CTkOptionMennu --- customtkinter/widgets/ctk_optionmenu.py | 3 ++- test/manual_integration_tests/test_variables.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/customtkinter/widgets/ctk_optionmenu.py b/customtkinter/widgets/ctk_optionmenu.py index e05e054..cc8601f 100644 --- a/customtkinter/widgets/ctk_optionmenu.py +++ b/customtkinter/widgets/ctk_optionmenu.py @@ -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 diff --git a/test/manual_integration_tests/test_variables.py b/test/manual_integration_tests/test_variables.py index 04bb0dc..c4595fa 100644 --- a/test/manual_integration_tests/test_variables.py +++ b/test/manual_integration_tests/test_variables.py @@ -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)