Command Line Progress Bar
peter
pjmakey2 at gmail.com
Wed Dec 26 06:06:02 EST 2012
On 12/26/2012 03:17 AM, Kevin Anthony wrote:
> Hello,
> I'm writing a file processing script(Linux), and i would like to have
> a progress bar. But i would also like to be able to print messages.
> Is there a simple way of doing this without implementing something
> like ncurses?
>
> --
> Thanks
> Kevin Anthony
> www.NoSideRacing.com <http://www.NoSideRacing.com>
>
> Do you use Banshee?
> Download the Community Extensions:
> http://banshee.fm/download/extensions/
>
>
I use this tecnique to make a progress bar in the console.
You just need to understand, that a progress bar is a
cross-multiplication http://en.wikipedia.org/wiki/Cross-multiplication.
import sys, time
def progressbar(value, total):
maspro = (100*value) / total
sys.stdout.write('\r[%s]%d%%' % ('#'*(maspro/10), maspro))
sys.stdout.flush()
for a in range(1, 1000):
progressbar(a, 100)
time.sleep(2)
You can't combine your progress bar with threading module
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20121226/b38397da/attachment.html>
More information about the Python-list
mailing list