From 1960c0b1e055539f2856256d5deac472f019fe13 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Mon, 8 May 2023 19:11:22 +0200 Subject: [PATCH] added text_color_disabled to configure of CTkOptionMenu #1559 --- .../windows/widgets/ctk_optionmenu.py | 26 +++++++++++-------- examples/simple_example.py | 1 + 2 files changed, 16 insertions(+), 11 deletions(-) diff --git a/customtkinter/windows/widgets/ctk_optionmenu.py b/customtkinter/windows/widgets/ctk_optionmenu.py index e9fa96c..cd9b1f9 100644 --- a/customtkinter/windows/widgets/ctk_optionmenu.py +++ b/customtkinter/windows/widgets/ctk_optionmenu.py @@ -243,6 +243,10 @@ class CTkOptionMenu(CTkBaseClass): self._text_color = self._check_color_type(kwargs.pop("text_color")) require_redraw = True + if "text_color_disabled" in kwargs: + self._text_color_disabled = self._check_color_type(kwargs.pop("text_color_disabled")) + require_redraw = True + if "dropdown_fg_color" in kwargs: self._dropdown_menu.configure(fg_color=kwargs.pop("dropdown_fg_color")) @@ -261,8 +265,12 @@ class CTkOptionMenu(CTkBaseClass): self._update_font() - if "command" in kwargs: - self._command = kwargs.pop("command") + if "dropdown_font" in kwargs: + self._dropdown_menu.configure(font=kwargs.pop("dropdown_font")) + + if "values" in kwargs: + self._values = kwargs.pop("values") + self._dropdown_menu.configure(values=self._values) if "variable" in kwargs: if self._variable is not None: # remove old callback @@ -277,19 +285,15 @@ class CTkOptionMenu(CTkBaseClass): else: self._variable = None - if "values" in kwargs: - self._values = kwargs.pop("values") - self._dropdown_menu.configure(values=self._values) - - if "dropdown_font" in kwargs: - self._dropdown_menu.configure(font=kwargs.pop("dropdown_font")) + if "state" in kwargs: + self._state = kwargs.pop("state") + require_redraw = True if "hover" in kwargs: self._hover = kwargs.pop("hover") - if "state" in kwargs: - self._state = kwargs.pop("state") - require_redraw = True + if "command" in kwargs: + self._command = kwargs.pop("command") if "dynamic_resizing" in kwargs: self._dynamic_resizing = kwargs.pop("dynamic_resizing") diff --git a/examples/simple_example.py b/examples/simple_example.py index 6999cc0..faf4fcb 100644 --- a/examples/simple_example.py +++ b/examples/simple_example.py @@ -37,6 +37,7 @@ entry_1.pack(pady=10, padx=10) optionmenu_1 = customtkinter.CTkOptionMenu(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."]) optionmenu_1.pack(pady=10, padx=10) optionmenu_1.set("CTkOptionMenu") +optionmenu_1.configure(state="disabled", text_color_disabled="red") combobox_1 = customtkinter.CTkComboBox(frame_1, values=["Option 1", "Option 2", "Option 42 long long long..."]) combobox_1.pack(pady=10, padx=10)