1+ ##############################################################################
12Text progress bar library for Python.
2- =====================================
3+ ##############################################################################
34
45Travis 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+ ******************************************************************************
1416Introduction
15- ------------
17+ ******************************************************************************
1618
1719.. highlights ::
1820
@@ -48,8 +50,9 @@ of widgets:
4850The progressbar module is very easy to use, yet very powerful. It will also
4951automatically enable features like auto-resizing when the system supports it.
5052
53+ ******************************************************************************
5154Links
52- -----
55+ ******************************************************************************
5356
5457* Documentation
5558 - http://progressbar-2.readthedocs.org/en/latest/
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+
0 commit comments