mirror of
https://github.com/tcsenpai/emesh.git
synced 2025-06-06 18:35:19 +00:00
31 lines
585 B
Python
31 lines
585 B
Python
import itertools
|
|
import threading
|
|
import time
|
|
import sys
|
|
|
|
done = True
|
|
message = ""
|
|
#here is the animation
|
|
def animate():
|
|
global done
|
|
global message
|
|
for c in itertools.cycle(['|', '/', '-', '\\']):
|
|
if done:
|
|
break
|
|
sys.stdout.write('\r' + message + ' ' + c)
|
|
sys.stdout.flush()
|
|
time.sleep(0.1)
|
|
sys.stdout.write('\rDone! \n')
|
|
|
|
def start(msg="loading..."):
|
|
global done
|
|
global message
|
|
done = False
|
|
message = msg
|
|
t = threading.Thread(target=animate)
|
|
t.start()
|
|
|
|
def stop():
|
|
global done
|
|
done = True
|