loading message thingy
Tim Williams
listserver at tdw.net
Wed Aug 11 05:45:50 EDT 2004
"Robbie" <user at domain.invalid> wrote in message
news:cfcndl$28em$1 at otis.netspace.net.au...
> Basically all I want to do is continuously write to the same line.
> So I could have a little rotating text thing showing that the script is
> working or display data ie, kb downloaded so far...
>
> ATM I am just calling a clear screen every pass with a little nap, nasty.
>
'\b' is a backspace, so.....
import sys,time
chars = ['|', '\\', '-', '/']
out = sys.stdout
def raw_print(txt):
out.write("\b" + txt)
out.flush()
while 1:
for x in range(len(chars)):
raw_print(chars[x])
time.sleep(0.5)
Save as a script and run it from your command prompt.
>Also it would be nice to be able to change more than one line so I could
>have 4 threads open downloading something with 4 lines each stating the
>current status of each thread
The code above should be able to handle this too with a small amount of
modding , I'd use a simple queue to get the information back from the
threads in an ordered and safe manner
HTH
More information about the Python-list
mailing list