From 5204683df4c723ffb67d18bdadda090f423cc545 Mon Sep 17 00:00:00 2001 From: Tom Schimansky Date: Sat, 17 Sep 2022 00:39:27 +0200 Subject: [PATCH] updated command calls of CTkSwitch, now commmand is called for .toggle() only --- customtkinter/widgets/ctk_progressbar.py | 14 +++++++++++--- customtkinter/widgets/ctk_switch.py | 6 ------ 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/customtkinter/widgets/ctk_progressbar.py b/customtkinter/widgets/ctk_progressbar.py index f6416ef..1c9494f 100644 --- a/customtkinter/widgets/ctk_progressbar.py +++ b/customtkinter/widgets/ctk_progressbar.py @@ -22,6 +22,8 @@ class CTkProgressBar(CTkBaseClass): border_width="default_theme", orient="horizontal", mode="determinate", + determinate_speed=1, + indeterminate_speed=1, **kwargs): # set default dimensions according to orientation @@ -53,10 +55,10 @@ class CTkProgressBar(CTkBaseClass): self.corner_radius = ThemeManager.theme["shape"]["progressbar_corner_radius"] if corner_radius == "default_theme" else corner_radius self.border_width = ThemeManager.theme["shape"]["progressbar_border_width"] if border_width == "default_theme" else border_width self.determinate_value = 0.5 # range 0-1 - self.determinate_speed = 1 # range 0-1 - self.indeterminate_value = 2 # range 0-1 + self.determinate_speed = determinate_speed # range 0-1 + self.indeterminate_value = 0 # range 0-inf self.indeterminate_width = 0.4 # range 0-1 - self.indeterminate_speed = 1 # range 0-1 to travel in 50ms + self.indeterminate_speed = indeterminate_speed # range 0-1 to travel in 50ms self.loop_running = False self.orient = orient self.mode = mode # "determinate" or "indeterminate" @@ -181,6 +183,12 @@ class CTkProgressBar(CTkBaseClass): self.mode = kwargs.pop("mode") require_redraw = True + if "determinate_speed" in kwargs: + self.determinate_speed = kwargs.pop("determinate_speed") + + if "indeterminate_speed" in kwargs: + self.indeterminate_speed = kwargs.pop("indeterminate_speed") + if "width" in kwargs: self.set_dimensions(width=kwargs["width"]) del kwargs["width"] diff --git a/customtkinter/widgets/ctk_switch.py b/customtkinter/widgets/ctk_switch.py index e9dc152..1f58518 100644 --- a/customtkinter/widgets/ctk_switch.py +++ b/customtkinter/widgets/ctk_switch.py @@ -228,9 +228,6 @@ class CTkSwitch(CTkBaseClass): self.variable.set(self.onvalue) self.variable_callback_blocked = False - if self.command is not None: - self.command() - def deselect(self, from_variable_callback=False): if self.state is not tkinter.DISABLED or from_variable_callback: self.check_state = False @@ -242,9 +239,6 @@ class CTkSwitch(CTkBaseClass): self.variable.set(self.offvalue) self.variable_callback_blocked = False - if self.command is not None: - self.command() - def get(self): return self.onvalue if self.check_state is True else self.offvalue