Created
July 24, 2015 17:34
-
-
Save pjflanagan/3f553922c9624e9fe614 to your computer and use it in GitHub Desktop.
This file contains 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 time | |
bar = 50 #length of bar in characters | |
loading = '0%'.ljust(bar) + '100%' | |
print(loading) | |
print('[', end="") | |
i = 0 | |
def load(percent): | |
#percent is decimal between 0 and 1 inclusive | |
#load(1) indicates that the process is done | |
#loading less than the amount already loaded does nothing | |
global i | |
while(i<percent*bar): | |
print('=', end="") | |
i+=1 | |
time.sleep(.05) | |
if(i==bar): | |
print("]") | |
return | |
x = 0 #test amount loaded | |
while(x<=1): | |
load(x) #example of usage | |
time.sleep(.25) #delay to show loading intervals | |
x+=.1 #load every ten percent just to show |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment