Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions loader.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
"""
Shaurya Pratap Singh
@shaurya-blip
Shows loading message while doing something.
"""

import itertools
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Always list dependencies in a requirements.txt file!

import threading
import time
import sys

# The task is not done right now
done = False


def animate(message="loading", endmessage="Done!"):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For smaller file size I would replace message with start and endmessage with end

for c in itertools.cycle(['|', '/', '-', '\\']):
if done:
break
sys.stdout.write(f'\r {message}' + c)
sys.stdout.flush()
time.sleep(0.1)
sys.stdout.write(f'\r {endmessage} ')

t = threading.Thread(target=lambda: animate(message="installing..",endmessage="Installation is done!!!"))
t.start()

# Code which you are running

"""
program.install()
"""

time.sleep(10)

# Then mark done as true and thus it will end the loading screen.
done = True