File tree Expand file tree Collapse file tree 1 file changed +38
-0
lines changed
Expand file tree Collapse file tree 1 file changed +38
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments