Skip to content

Instantly share code, notes, and snippets.

@dannluciano
Created June 12, 2021 19:53
Show Gist options
  • Save dannluciano/1ff6f6029f4b8f384eb0d6e4322da859 to your computer and use it in GitHub Desktop.
Save dannluciano/1ff6f6029f4b8f384eb0d6e4322da859 to your computer and use it in GitHub Desktop.
Loader in Python
import sys
import time
cols = 59
steps = 100
if len(sys.argv) > 2:
steps = int(sys.argv[1])
for s in range(steps):
percent = s / steps * cols-1
real_percent = s / steps * 100
print(f"\r{real_percent:6.2f} [", end='')
i = 0
while i < percent and i < cols:
i+=1
print('=', end='')
print('>', end='')
i+=1
while i > percent and i < cols:
i+=1
print(' ', end='')
loading = "-\\|/"
char = loading[s%4]
print(f"] {char} ETA {steps-s}", end='', flush=True)
time.sleep(1)
print("\nFinished!")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment