Python: Run a progess bar and work simultaneously?
- by DanielTA
I want to know how to run a progress bar and some other work simultaneously, then when the work is done, stop the progress bar in Python (2.7.x)
import sys, time
def progress_bar():
while True:
for c in ['-','\\','|','/']:
sys.stdout.write('\r' + "Working " + c)
sys.stdout.flush()
time.sleep(0.2)
def work():
*doing hard work*
How would I be able to do something like:
progress_bar() #run in background?
work()
*stop progress bar*
print "\nThe work is done!"