From 60b13bf2157930a98e08d613cc8ac452c70f10d7 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 30 May 2022 16:46:36 +0200 Subject: [PATCH] fixes for DropdownMenu --- customtkinter/draw_engine.py | 4 ++-- customtkinter/widgets/ctk_optionmenu.py | 13 +++++++------ test/manual_integration_tests/test_optionmenu.py | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/customtkinter/draw_engine.py b/customtkinter/draw_engine.py index 8d6e0d9..a8a68af 100644 --- a/customtkinter/draw_engine.py +++ b/customtkinter/draw_engine.py @@ -998,7 +998,7 @@ class DrawEngine: if self.preferred_drawing_method == "polygon_shapes" or self.preferred_drawing_method == "circle_shapes": if not self._canvas.find_withtag("dropdown_arrow"): - self._canvas.create_line(0, 0, 0, 0, tags=("dropdown_arrow"), width=round(size / 4), joinstyle=tkinter.MITER, capstyle=tkinter.ROUND) + self._canvas.create_line(0, 0, 0, 0, tags="dropdown_arrow", width=round(size / 3), joinstyle=tkinter.ROUND, capstyle=tkinter.ROUND) self._canvas.tag_raise("dropdown_arrow") requires_recoloring = True @@ -1012,7 +1012,7 @@ class DrawEngine: elif self.preferred_drawing_method == "font_shapes": if not self._canvas.find_withtag("dropdown_arrow"): - self._canvas.create_text(0, 0, text="Y", font=("CustomTkinter_shapes_font", -size), tags=("dropdown_arrow"), anchor=tkinter.CENTER) + self._canvas.create_text(0, 0, text="Y", font=("CustomTkinter_shapes_font", -size), tags="dropdown_arrow", anchor=tkinter.CENTER) self._canvas.tag_raise("dropdown_arrow") requires_recoloring = True diff --git a/customtkinter/widgets/ctk_optionmenu.py b/customtkinter/widgets/ctk_optionmenu.py index 1f71982..4f72e29 100644 --- a/customtkinter/widgets/ctk_optionmenu.py +++ b/customtkinter/widgets/ctk_optionmenu.py @@ -292,6 +292,13 @@ class CTkOptionMenu(CTkBaseClass): self.variable.set(self.current_value) self.variable_callback_blocked = False + if not from_variable_callback: + if self.function is not None: + try: + self.function(self.current_value) + except Exception: + pass + def get(self) -> str: return self.current_value @@ -303,9 +310,3 @@ class CTkOptionMenu(CTkBaseClass): self.on_leave() self.click_animation_running = True self.after(100, self.click_animation) - - if self.function is not None: - try: - self.function() - except Exception: - pass diff --git a/test/manual_integration_tests/test_optionmenu.py b/test/manual_integration_tests/test_optionmenu.py index 0b75a16..7e58728 100644 --- a/test/manual_integration_tests/test_optionmenu.py +++ b/test/manual_integration_tests/test_optionmenu.py @@ -7,7 +7,7 @@ ws.geometry('400x300') def display_selected(choice): choice = variable.get() - print(choice) + print("display_selected", choice) countries = ['Bahamas','Canada', 'Cuba','United States']