Last active
February 9, 2024 21:04
-
-
Save fastfingertips/4e8adff9968b074b9e2b710d13798c5a to your computer and use it in GitHub Desktop.
Basic loading effect.
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 time | |
def progression_bar(total_time=5, loading_msg="Loading...", end_msg="Completed."): | |
max_str = max(len(loading_msg), len(end_msg)) | |
loading_msg = loading_msg.ljust(max_str) | |
end_msg = end_msg.ljust(max_str) | |
num_bar = 10 | |
sleep_intvl = total_time/num_bar | |
for i in range(1,num_bar+1): | |
print(f"\r{loading_msg} {i/num_bar:.1%}", end="") | |
time.sleep(sleep_intvl) | |
print(f"\r{end_msg}") | |
if __name__ == "__main__": | |
progression_bar() | |
print('Hello World!') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment