Hello Steven,
I added the pipe char '|' to have a complete spinner!
This would be set as a function for my wait routine installer.
Thanks to share!
Karim
On 12/10/2010 09:51 PM, Steven D'Aprano wrote:
Modulok wrote:
List,
Forgive me if I don't describe this well, I'm new to it:
[snip description of a progress bar]
Here's one way:
import time, sys
f = sys.stdout
for i in range(20):
time.sleep(1) # do some work
f.write('=')
f.flush() # make the change visible immediately
else:
f.write('\n')
You might be able to get the same effect with print, but it's probably
easier using sys.stdout directly.
Here's another way, which *must* use stdout and not print.
for i in range(20):
percentage = i/20.0
spinner = '/-\\-'[i % 4]
f.write("Progress: %5.2f%% %s %s>\r" %
(percentage, spinner, '='*(i+1)))
f.flush()
time.sleep(1)
else:
f.write('\n')
_______________________________________________
Tutor maillist - Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor