loading message thingy
Tim Williams
listserver at tdw.net
Wed Aug 11 09:01:26 EDT 2004
----- Original Message -----
From: "Tim Williams" <listserver at tdw.net>
> "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)
Thinking about it, '\b' can cancel out the extra space at the end of a
"print char," (with the comma on the end)
so, this does the same thing ....
import time
chars = ['|', '\\', '-', '/']
while 1:
for x in range(len(chars)):
print "\b\b" + chars[x],
time.sleep(0.5)
More information about the Python-list
mailing list