appear message after loading bar finishes running python

Solutions on MaxInterview for appear message after loading bar finishes running python by the best coders in the world

showing results for - "appear message after loading bar finishes running python"
Lia
11 Aug 2017
1import itertools
2import threading
3import time
4import sys
5
6done = False
7#here is the animation
8def animate():
9    for c in itertools.cycle(['|', '/', '-', '\\']):
10        if done:
11            break
12        sys.stdout.write('\rloading ' + c)
13        sys.stdout.flush()
14        time.sleep(0.1)
15    sys.stdout.write('\rDone!     ')
16
17t = threading.Thread(target=animate)
18t.start()
19
20#long process here
21time.sleep(10)
22done = True
23
24import time
25
26print("custom message")
27