Skip to content

Instantly share code, notes, and snippets.

@conor-f
Created May 18, 2022 15:52
Show Gist options
  • Save conor-f/34e32b645ec91f6e5dc66456f01746a7 to your computer and use it in GitHub Desktop.
Save conor-f/34e32b645ec91f6e5dc66456f01746a7 to your computer and use it in GitHub Desktop.
A very basic python3.6+ loading bar
# 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