Created
February 5, 2014 12:10
-
-
Save wpjunior/8822393 to your computer and use it in GitHub Desktop.
terminal progressbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
# | |
# Copyright (C) 2014 Wilson Pinto Júnior <[email protected]> | |
# | |
import time | |
import sys | |
def print_in_line(text): | |
sys.stdout.write(text) | |
sys.stdout.write('\r') | |
sys.stdout.flush() | |
def print_progressbar(value, text=None): | |
inner = ('#' * (i / 4)).ljust(25, '_') | |
if text: | |
print_in_line("%s [%s] %d %%" % (text, inner, i)) | |
else: | |
print_in_line("[%s] %d %%" % (inner, i)) | |
for i in xrange(101): | |
print_progressbar(i, "Testing") | |
time.sleep(0.05) | |
print "\nFinished!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment