Created
September 18, 2018 17:20
-
-
Save qqpann/20d7bcbf9b5aa891738d5c9ae044eaa0 to your computer and use it in GitHub Desktop.
[Python Progress Bar] Python Progress Bar #python #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
import sys | |
import time | |
toolbar_width = 40 | |
# setup toolbar | |
sys.stdout.write("[%s]" % (" " * toolbar_width)) | |
sys.stdout.flush() | |
# return to start of line, after '[' | |
sys.stdout.write("\b" * (toolbar_width + 1)) | |
for i in range(toolbar_width): | |
time.sleep(0.1) # do real work here | |
# update the bar | |
sys.stdout.write("-") | |
sys.stdout.flush() | |
sys.stdout.write("\n") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment