Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GUI #29

Merged
merged 7 commits into from
Oct 9, 2015
Merged

GUI #29

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
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ env:
- TOXENV=pypy3
- TOXENV=flake8
install:
- pip install 'coverage<4'
- pip install tox coveralls
script:
- tox
Expand Down
28 changes: 17 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ You can also use `trange(N)` as a shortcut for `tqdm(xrange(N))`

![Screenshot](tqdm.gif)

Overhead is low -- about 55ns per iteration. By comparison, our esteemed
competition, [ProgressBar](https://code.google.com/p/python-progressbar/), has
an 878ns/iter overhead. It's a matter of taste, but we also like to think our
Overhead is low -- about 60ns per iteration (80ns with `gui=True`).
By comparison, our esteemed
competition [ProgressBar](https://code.google.com/p/python-progressbar/) has
an 800ns/iter overhead. It's a matter of taste, but we also like to think our
version is much more visually appealing.

## Installation
Expand All @@ -42,7 +43,7 @@ class tqdm:
def __init__(self, iterable=None, desc=None, total=None, leave=False,
file=sys.stderr, ncols=None, mininterval=0.1,
miniters=None, ascii=None, disable=False,
unit='it', unit_scale=False):
unit='it', unit_scale=False, gui=False):
"""
Parameters
----------
Expand All @@ -54,7 +55,9 @@ class tqdm:
total : int, optional
The number of expected iterations. If not given, len(iterable) is
used if possible. As a last resort, only basic progress
statistics are displayed (no ETA, no progressbar).
statistics are displayed (no ETA, no progressbar). If `gui` is
True and this parameter needs subsequent updating, specify an
initial arbitrary large positive integer, e.g. int(9e9).
leave : bool, optional
If [default: False], removes all traces of the progressbar
upon termination of iteration.
Expand All @@ -64,9 +67,10 @@ class tqdm:
methods.
ncols : int, optional
The width of the entire output message. If specified, dynamically
resizes the progress meter to stay within this bound
[default: None]. The fallback meter width is 10 for the progress
bar + no limit for the iterations counter and statistics.
resizes the progressbar to stay within this bound
[default: None]. The fallback is a meter width of 10 and no
limit for the counter and statistics. If 0, will not print any
meter (only stats).
mininterval : float, optional
Minimum progress update interval, in seconds [default: 0.1].
miniters : int, optional
Expand All @@ -85,6 +89,9 @@ class tqdm:
automatically and a metric prefix following the
International System of Units standard will be added
(kilo, mega, etc.) [default: False].
gui : bool, optional
If set, will attempt to use matplotlib animations for a
graphical output [default: false].

Returns
-------
Expand All @@ -102,7 +109,7 @@ class tqdm:
... t.update(len(current_buffer))
>>> t.close()
The last line is highly recommended, but possibly not necessary if
`t.update()` will be called in such a was that `filesize` will be
`t.update()` will be called in such a way that `filesize` will be
exactly reached and printed.

Parameters
Expand All @@ -114,8 +121,7 @@ class tqdm:

def close(self):
"""
Call this method to force print the last progress bar update
based on the latest n value
Cleanup and (if leave=False) close the progressbar.
"""

def trange(*args, **kwargs):
Expand Down
11 changes: 9 additions & 2 deletions examples/simple_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,17 @@
sleep(0.1)

# Profiling/overhead tests
stmts = ('[i for i in xrange(int(1e8))]',
stmts = (
# Benchmark
'[i for i in xrange(int(1e8))]',
# Basic demo
'import tqdm; [i for i in tqdm.trange(int(1e8))]',
# Some decorations
'import tqdm; [i for i in tqdm.trange(int(1e8), miniters=int(1e6),'
' ascii=False, desc="cool")]',
' ascii=True, desc="cool")]',
# Experimental GUI demo
'import tqdm; [i for i in tqdm.trange(int(1e8), gui=True)]',
# Comparison to https://code.google.com/p/python-progressbar/
'from progressbar.progressbar import ProgressBar;'
' [i for i in ProgressBar()(xrange(int(1e8)))]')
for s in stmts:
Expand Down
2 changes: 2 additions & 0 deletions examples/tqdm_wget.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ def inner(b=1, bsize=1, tsize=None, close=False):
Size of each block (in tqdm units) [default: 1].
tsize : int, optional
Total size (in tqdm units). If [default: None] remains unchanged.
close : bool, optional
Whether to cleanly terminate the progressbar [default: False].
'''
if close:
t.close()
Expand Down
2 changes: 1 addition & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ envlist = py26, py27, py32, py33, py34, pypy, pypy3, flake8
passenv = TRAVIS TRAVIS_JOB_ID TRAVIS_BRANCH
deps =
nose
coverage
coverage<4
coveralls
commands =
nosetests --with-coverage --cover-package=tqdm -v tqdm/
Expand Down
Loading