From 6bf877eebc64e741110e24b26dc559b4adbfb3d5 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 22 Oct 2022 15:24:15 +0200 Subject: [PATCH] added mising configure argument for CTkButton #544 --- customtkinter/widgets/ctk_button.py | 78 ++++++++++--------- ...plex_example_new.py => complex_example.py} | 2 - 2 files changed, 41 insertions(+), 39 deletions(-) rename examples/{complex_example_new.py => complex_example.py} (99%) diff --git a/customtkinter/widgets/ctk_button.py b/customtkinter/widgets/ctk_button.py index 6a339b4..85e2144 100644 --- a/customtkinter/widgets/ctk_button.py +++ b/customtkinter/widgets/ctk_button.py @@ -279,6 +279,38 @@ class CTkButton(CTkBaseClass): pady=(self._apply_widget_scaling(self._border_width), 2)) def configure(self, require_redraw=False, **kwargs): + if "corner_radius" in kwargs: + self._corner_radius = kwargs.pop("corner_radius") + require_redraw = True + + if "border_width" in kwargs: + self._border_width = kwargs.pop("border_width") + require_redraw = True + + if "fg_color" in kwargs: + self._fg_color = kwargs.pop("fg_color") + require_redraw = True + + if "hover_color" in kwargs: + self._hover_color = kwargs.pop("hover_color") + require_redraw = True + + if "border_color" in kwargs: + self._border_color = kwargs.pop("border_color") + require_redraw = True + + if "text_color" in kwargs: + self._text_color = kwargs.pop("text_color") + require_redraw = True + + if "text_color_disabled" in kwargs: + self._text_color_disabled = kwargs.pop("text_color_disabled") + require_redraw = True + + if "background_corner_colors" in kwargs: + self._background_corner_colors = kwargs.pop("background_corner_colors") + require_redraw = True + if "text" in kwargs: self._text = kwargs.pop("text") if self._text_label is None: @@ -295,41 +327,18 @@ class CTkButton(CTkBaseClass): self._update_font() - if "state" in kwargs: - self._state = kwargs.pop("state") - self._set_cursor() - require_redraw = True + if "textvariable" in kwargs: + self._textvariable = kwargs.pop("textvariable") + if self._text_label is not None: + self._text_label.configure(textvariable=self._textvariable) if "image" in kwargs: self._image = kwargs.pop("image") require_redraw = True - if "corner_radius" in kwargs: - self._corner_radius = kwargs.pop("corner_radius") - require_redraw = True - - if "border_width" in kwargs: - self._border_width = kwargs.pop("border_width") - require_redraw = True - - if "compound" in kwargs: - self._compound = kwargs.pop("compound") - require_redraw = True - - if "fg_color" in kwargs: - self._fg_color = kwargs.pop("fg_color") - require_redraw = True - - if "border_color" in kwargs: - self._border_color = kwargs.pop("border_color") - require_redraw = True - - if "hover_color" in kwargs: - self._hover_color = kwargs.pop("hover_color") - require_redraw = True - - if "text_color" in kwargs: - self._text_color = kwargs.pop("text_color") + if "state" in kwargs: + self._state = kwargs.pop("state") + self._set_cursor() require_redraw = True if "hover" in kwargs: @@ -338,13 +347,8 @@ class CTkButton(CTkBaseClass): if "command" in kwargs: self._command = kwargs.pop("command") - if "textvariable" in kwargs: - self._textvariable = kwargs.pop("textvariable") - if self._text_label is not None: - self._text_label.configure(textvariable=self._textvariable) - - if "background_corner_colors" in kwargs: - self._background_corner_colors = kwargs.pop("background_corner_colors") + if "compound" in kwargs: + self._compound = kwargs.pop("compound") require_redraw = True super().configure(require_redraw=require_redraw, **kwargs) diff --git a/examples/complex_example_new.py b/examples/complex_example.py similarity index 99% rename from examples/complex_example_new.py rename to examples/complex_example.py index 72a5a6f..4c0eb2f 100644 --- a/examples/complex_example_new.py +++ b/examples/complex_example.py @@ -140,8 +140,6 @@ class App(customtkinter.CTk): self.seg_button_1.configure(values=["CTkSegmentedButton", "Value 2", "Value 3"]) self.seg_button_1.set("Value 2") - # self.attributes("-fullscreen", True) - def open_input_dialog(self): dialog = customtkinter.CTkInputDialog(master=self, text="Type in a number:", title="CTkInputDialog") print("CTkInputDialog:", dialog.get_input())