Skip to content

Commit

Permalink
尝试修正进度条动画的抖动
Browse files Browse the repository at this point in the history
  • Loading branch information
TransparentLC committed Jan 25, 2024
1 parent 07ee4d8 commit b95c2ef
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -526,14 +526,21 @@ def writeToOutput(self, s: str):
progressTo = (self.progressValue[0] + self.progressValue[1]) / self.progressValue[2] * 100
if progressFrom != progressTo:
def anim():
if self.progressAnimation[3] is None:
return
# print(f'Before anim {self.progressAnimation}')
self.vardoubleProgress.set(self.progressAnimation[0] + (self.progressAnimation[1] - self.progressAnimation[0]) * (lambda x: 1 - (1 - x) ** 3)(self.progressAnimation[2]))
self.progressAnimation[2] += 1 / 10
if self.progressAnimation[2] < 1:
self.progressAnimation[3] = self.progressbar.after(10, anim)
else:
self.progressAnimation[3] = None
# print(f'After anim {self.progressAnimation}')
if self.progressAnimation[3]:
self.progressbar.after_cancel(self.progressAnimation[3])
afterId = self.progressAnimation[3]
self.progressAnimation[3] = None
self.progressbar.after_cancel(afterId)
# print(f'Cancel {afterId}')
self.progressAnimation[0] = progressFrom
self.progressAnimation[1] = progressTo
self.progressAnimation[2] = 0
Expand Down

0 comments on commit b95c2ef

Please sign in to comment.