Skip to content

Commit 38c1889

Browse files
committed
improved docs
1 parent 72cf4c7 commit 38c1889

3 files changed

Lines changed: 76 additions & 74 deletions

File tree

README.rst

Lines changed: 76 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
##############################################################################
12
Text progress bar library for Python.
2-
=====================================
3+
##############################################################################
34

45
Travis status:
56

@@ -11,8 +12,9 @@ Coverage:
1112
.. image:: https://coveralls.io/repos/WoLpH/python-progressbar/badge.png?branch=master
1213
:target: https://coveralls.io/r/WoLpH/python-progressbar?branch=master
1314

15+
******************************************************************************
1416
Introduction
15-
------------
17+
******************************************************************************
1618

1719
.. highlights::
1820

@@ -48,8 +50,9 @@ of widgets:
4850
The progressbar module is very easy to use, yet very powerful. It will also
4951
automatically enable features like auto-resizing when the system supports it.
5052

53+
******************************************************************************
5154
Links
52-
-----
55+
******************************************************************************
5356

5457
* Documentation
5558
- http://progressbar-2.readthedocs.org/en/latest/
@@ -62,3 +65,73 @@ Links
6265
* My blog
6366
- http://w.wol.ph/
6467

68+
******************************************************************************
69+
Usage
70+
******************************************************************************
71+
72+
There are many ways to use Python Progressbar, you can see a few basic examples
73+
here but there are many more in the :doc:`examples` file.
74+
75+
Wrapping an iterable
76+
==============================================================================
77+
::
78+
79+
import time
80+
import progressbar
81+
82+
bar = progressbar.ProgressBar()
83+
for i in bar(range(100)):
84+
time.sleep(0.02)
85+
86+
Context wrapper
87+
==============================================================================
88+
::
89+
90+
import time
91+
import progressbar
92+
93+
with progressbar.ProgressBar(max_value=10) as bar:
94+
for i in range(10):
95+
time.sleep(0.1)
96+
bar.update(i)
97+
98+
Combining progressbars with print output
99+
==============================================================================
100+
::
101+
102+
import time
103+
import progressbar
104+
105+
bar = progressbar.ProgressBar(redirect_stdout=True)
106+
for i in range(100):
107+
print 'Some text', i
108+
time.sleep(0.1)
109+
bar.update(i)
110+
111+
Progressbar with unknown length
112+
==============================================================================
113+
::
114+
115+
import time
116+
import progressbar
117+
118+
bar = progressbar.ProgressBar(max_value=progressbar.UnknownLength)
119+
for i in range(20):
120+
time.sleep(0.1)
121+
bar.update(i)
122+
123+
Bar with custom widgets
124+
==============================================================================
125+
::
126+
127+
import time
128+
import progressbar
129+
130+
bar = progressbar.ProgressBar(widgets=[
131+
' [', progressbar.Timer(), '] ',
132+
progressbar.Bar(),
133+
' (', progressbar.ETA(), ') ',
134+
])
135+
for i in bar(range(20)):
136+
time.sleep(0.1)
137+

docs/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Contents
99
.. toctree::
1010
:maxdepth: 4
1111

12-
usage
1312
examples
1413
contributing
1514
history

docs/usage.rst

Lines changed: 0 additions & 70 deletions
This file was deleted.

0 commit comments

Comments
 (0)