diff options
Diffstat (limited to 'ttystatus/progressbar.py')
-rw-r--r-- | ttystatus/progressbar.py | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/ttystatus/progressbar.py b/ttystatus/progressbar.py index 54ca99f..cd0f1a3 100644 --- a/ttystatus/progressbar.py +++ b/ttystatus/progressbar.py @@ -20,15 +20,16 @@ import ttystatus class ProgressBar(ttystatus.Widget): '''Display a progress bar.''' + + static_width = False - def __init__(self, done_name, total_name, width): + def __init__(self, done_name, total_name): self.done_name = done_name self.total_name = total_name self.done = 0 self.total = 1 - self.width = width - def render(self): + def render(self, width): try: done = float(self.done) total = float(self.total) @@ -39,8 +40,8 @@ class ProgressBar(ttystatus.Widget): fraction = 0 else: fraction = done / total - n_stars = int(round(fraction * self.width)) - n_dashes = int(self.width - n_stars) + n_stars = int(round(fraction * width)) + n_dashes = int(width - n_stars) return ('#' * n_stars) + ('-' * n_dashes) def update(self, master): |