mirror of
https://github.com/TomSchimansky/CustomTkinter.git
synced 2023-08-10 21:13:13 +03:00
fixed progressbar start stop speed increase #775
This commit is contained in:
parent
2c7b2c5030
commit
dd223a15b5
@ -58,6 +58,7 @@ class CTkProgressBar(CTkBaseClass):
|
||||
self._variable = variable
|
||||
self._variable_callback_blocked = False
|
||||
self._variable_callback_name = None
|
||||
self._loop_after_id = None
|
||||
|
||||
# shape
|
||||
self._corner_radius = ThemeManager.theme["CTkProgressBar"]["corner_radius"] if corner_radius is None else corner_radius
|
||||
@ -249,13 +250,15 @@ class CTkProgressBar(CTkBaseClass):
|
||||
return self._determinate_value
|
||||
|
||||
def start(self):
|
||||
""" start indeterminate mode """
|
||||
""" start automatic mode """
|
||||
if not self._loop_running:
|
||||
self._loop_running = True
|
||||
self._internal_loop()
|
||||
|
||||
def stop(self):
|
||||
""" stop indeterminate mode """
|
||||
""" stop automatic mode """
|
||||
if self._loop_after_id is not None:
|
||||
self.after_cancel(self._loop_after_id)
|
||||
self._loop_running = False
|
||||
|
||||
def _internal_loop(self):
|
||||
@ -265,13 +268,14 @@ class CTkProgressBar(CTkBaseClass):
|
||||
if self._determinate_value > 1:
|
||||
self._determinate_value -= 1
|
||||
self._draw()
|
||||
self.after(20, self._internal_loop)
|
||||
self._loop_after_id = self.after(20, self._internal_loop)
|
||||
else:
|
||||
self._indeterminate_value += self._indeterminate_speed
|
||||
self._draw()
|
||||
self.after(20, self._internal_loop)
|
||||
self._loop_after_id = self.after(20, self._internal_loop)
|
||||
|
||||
def step(self):
|
||||
""" increase progress """
|
||||
if self._mode == "determinate":
|
||||
self._determinate_value += self._determinate_speed / 50
|
||||
if self._determinate_value > 1:
|
||||
|
@ -70,11 +70,4 @@ tabview_1.pack(pady=10, padx=10)
|
||||
tabview_1.add("CTkTabview")
|
||||
tabview_1.add("Tab 2")
|
||||
|
||||
progressbar_1.configure(mode="indeterminate")
|
||||
progressbar_1.start()
|
||||
#progressbar_1.stop()
|
||||
#progressbar_1.start()
|
||||
#progressbar_1.stop()
|
||||
#progressbar_1.start()
|
||||
|
||||
app.mainloop()
|
||||
|
Loading…
Reference in New Issue
Block a user