Issue
To implement a status bar like below:
[========== ] 45%
[================ ] 60%
[==========================] 100%
I want to this to be printed out to stdout, and keep refreshing it, not print to another line. How to do this?
Solution
There's a Python module that you can get from PyPI called progressbar
that implements such functionality. If you don't mind adding a dependency, it's a good solution. Otherwise, go with one of the other answers.
A simple example of how to use it:
import progressbar
from time import sleep
bar = progressbar.ProgressBar(maxval=20, \
widgets=[progressbar.Bar('=', '[', ']'), ' ', progressbar.Percentage()])
bar.start()
for i in xrange(20):
bar.update(i+1)
sleep(0.1)
bar.finish()
To install it, you can use easy_install progressbar
, or pip install progressbar
if you prefer pip.
Answered By - icktoofay
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.