Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,14 +261,14 @@ def with_example20():


@example
def with_example21():
def with_example21a():
with ProgressBar(maxval=1, redirect_stdout=True) as progress:
print('', file=sys.stdout)
progress.update(0)


@example
def with_example21():
def with_example21b():
with ProgressBar(maxval=1, redirect_stderr=True) as progress:
print('', file=sys.stderr)
progress.update(0)
Expand Down Expand Up @@ -296,6 +296,27 @@ def example23():
progress.update(i)


@example
def example24():
pbar = ProgressBar(widgets=[Percentage(), Bar()], maxval=10).start()
for i in range(10):
# do something
time.sleep(0.001)
pbar += 1
pbar.finish()


@example
def example25():
widgets = ['Test: ', Percentage(), ' ', Bar(marker=RotatingMarker()),
' ', ETA(), ' ', FileTransferSpeed()]
pbar = ProgressBar(widgets=widgets, maxval=1000, redirect_stdout=True).start()
for i in range(100):
# do something
pbar += 10
pbar.finish()


if __name__ == '__main__':
try:
for example in examples:
Expand Down
5 changes: 5 additions & 0 deletions progressbar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,11 @@ def __enter__(self):
# an iterator.
next = __next__

def __iadd__(self, value):
'Updates the ProgressBar by adding a new value.'
self.update(self.currval + value)
return self

def _env_size(self):
'Tries to find the term_width from the environment.'

Expand Down