Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added nicer defaults

  • Loading branch information...
commit e1e266443ac722643f3a7c89d5f3e6e4452ed400 1 parent f071623
@WoLpH authored
Showing with 20 additions and 1 deletion.
  1. +7 −1 progressbar/__init__.py
  2. +13 −0 progressbar/widgets.py
View
8 progressbar/__init__.py
@@ -119,7 +119,13 @@ class ProgressBar(object):
_DEFAULT_MAXVAL = 100
_DEFAULT_TERMSIZE = 80
- _DEFAULT_WIDGETS = [Percentage(), ' ', Bar()]
+ _DEFAULT_WIDGETS = [
+ Count(), ' ',
+ Timer(), ' ',
+ ETA(), ' ',
+ Percentage(), ' ',
+ Bar(),
+ ]
def __init__(self, maxval=None, widgets=None, term_width=None, poll=1,
left_justify=True, fd=sys.stderr):
View
13 progressbar/widgets.py
@@ -165,6 +165,19 @@ def update(self, pbar):
RotatingMarker = AnimatedMarker
+class Count(Widget):
+ 'Display the total and current count'
+
+ __slots__ = ('format',)
+
+ def __init__(self, format='% *d/%d'):
+ self.format = format
+
+ def update(self, pbar):
+ decimals = int(math.ceil(math.log10(pbar.maxval)))
+ return self.format % (decimals, pbar.currval, pbar.maxval)
+
+
class Counter(Widget):
'Displays the current count'
Please sign in to comment.
Something went wrong with that request. Please try again.