Created
May 18, 2022 15:52
-
-
Save conor-f/34e32b645ec91f6e5dc66456f01746a7 to your computer and use it in GitHub Desktop.
A very basic python3.6+ loading bar
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
# Created after reading http://xn--rpa.cc/irl/term.html | |
from time import sleep | |
def scroll( | |
width=20, | |
dots=5, | |
on_char="*", | |
off_char="-", | |
delay=0.05, | |
current_index=0 | |
): | |
print_str = list(off_char * width) | |
for i in range(dots): | |
print_str[(current_index + i) % width] = on_char | |
print( | |
f"{''.join(print_str)}\r", | |
end="" | |
) | |
sleep(delay) | |
scroll( | |
width=width, | |
dots=dots, | |
on_char=on_char, | |
off_char=off_char, | |
delay=delay, | |
current_index=((current_index + 1) % width) | |
) | |
scroll() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment