Skip to content

Commit bffbaa5

Browse files
Merge pull request #1315 from shaurya-blip/patch-2
Loading message in python
2 parents 6abfee3 + 61128bd commit bffbaa5

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

loader.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
"""
2+
Shaurya Pratap Singh
3+
@shaurya-blip
4+
5+
Shows loading message while doing something.
6+
"""
7+
8+
import itertools
9+
import threading
10+
import time
11+
import sys
12+
13+
# The task is not done right now
14+
done = False
15+
16+
17+
def animate(message="loading", endmessage="Done!"):
18+
for c in itertools.cycle(['|', '/', '-', '\\']):
19+
if done:
20+
break
21+
sys.stdout.write(f'\r {message}' + c)
22+
sys.stdout.flush()
23+
time.sleep(0.1)
24+
sys.stdout.write(f'\r {endmessage} ')
25+
26+
t = threading.Thread(target=lambda: animate(message="installing..",endmessage="Installation is done!!!"))
27+
t.start()
28+
29+
# Code which you are running
30+
31+
"""
32+
program.install()
33+
"""
34+
35+
time.sleep(10)
36+
37+
# Then mark done as true and thus it will end the loading screen.
38+
done = True

0 commit comments

Comments
 (0)