Python: Run a progess bar and work simultaneously?
Posted
by
DanielTA
on Stack Overflow
See other posts from Stack Overflow
or by DanielTA
Published on 2012-11-25T03:09:29Z
Indexed on
2012/11/25
23:04 UTC
Read the original article
Hit count: 150
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!"
© Stack Overflow or respective owner