updated command calls of CTkSwitch, now commmand is called for .toggle() only

This commit is contained in:
Tom Schimansky 2022-09-17 00:39:27 +02:00
parent 98c4c669a6
commit 5204683df4
2 changed files with 11 additions and 9 deletions

View File

@ -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"]

View File

@ -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