Browse Source

Progress bar

pull/3/head
Jure Šorn 6 years ago
parent
commit
779affeda6
1 changed files with 22 additions and 0 deletions
  1. 22
      README.md

22
README.md

@ -850,6 +850,28 @@ wf.writeframes(b''.join(frames))
wf.close()
```
Progress Bar
------------
#### Basic:
```python
class Progressbar():
def __init__(self, steps, width=40):
self.steps = steps
self.width = width
self.filled = 0
self.counter = 0
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:
self.filled += 1
sys.stdout.write("-")
sys.stdout.flush()
if self.counter == self.steps:
sys.stdout.write("\n")
```

Loading…
Cancel
Save