Last active
January 3, 2016 08:49
-
-
Save fcrespo82/8438526 to your computer and use it in GitHub Desktop.
Progress bar module for python. Super simple to use.Any questions find me @fcrespo82 on twitter and app.net
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 | |
def progressbar(total, value, size=70, fill_char="#", empty_char="-"): | |
if value > total: | |
raise Exception("'value' must be <= 'total'") | |
multiplier = (size*1.0)/total | |
fill=int(round(value*multiplier)) | |
empty=int(round((total-value)*multiplier)) | |
print("[{}{}]".format(fill_char*fill, empty_char*empty)) | |
def main(): | |
print("Progress Bar demo\n") | |
demo="progressbar(100, 50)" | |
print(demo) | |
eval(demo) | |
demo="progressbar(100, 50, 30)" | |
print(demo) | |
eval(demo) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment