This is pretty much what I have right now:
import time
import sys
done = \'false\'
#here is the animation
def animate():
while done == \'false\':
import sys, time, threading
def your_function_name() :
# do something here
def loadingAnimation(process) :
while process.isAlive() :
chars = "/—\|"
for char in chars:
sys.stdout.write('\r'+'loading '+char)
time.sleep(.1)
sys.stdout.flush()
loading_process = threading.Thread(target=your_function_name)
loading_process.start()
animated_loading(loading_process)
loading_process.join()