Skip to content

Instantly share code, notes, and snippets.

@fcrespo82
Last active January 3, 2016 08:49
Show Gist options
  • Save fcrespo82/8438526 to your computer and use it in GitHub Desktop.
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
#!/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