From 9dda4fc580a0e0c8eaceac9c0fcb0efef89f81bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jure=20=C5=A0orn?= Date: Wed, 18 Apr 2018 14:01:50 +0200 Subject: [PATCH] Progress bar --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a07af8d..efab3f0 100644 --- a/README.md +++ b/README.md @@ -860,13 +860,15 @@ class Progressbar(): self.width = width self.filled = 0 self.counter = 0 + self.treshold = self.filled * self.steps / self.width sys.stdout.write(f"[{' ' * width}]") sys.stdout.flush() sys.stdout.write('\b' * (width + 1)) def tick(self): self.counter += 1 - while self.counter > self.filled * self.steps / self.width: + while self.counter > self.treshold: self.filled += 1 + self.treshold = self.filled * self.steps / self.width sys.stdout.write("-") sys.stdout.flush() if self.counter == self.steps: