Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Python (http://www.velocityreviews.com/forums/f43-python.html)
-   -   Typing letters slowly using sys (http://www.velocityreviews.com/forums/t959445-typing-letters-slowly-using-sys.html)

mattgraves7@gmail.com 04-05-2013 02:04 PM

Typing letters slowly using sys
 
I am using sys to give the effect that I am typing letters slowly. Basically what I want to have happen is have it show "Loading......" with the word loading appearing instantly and then the periods appearing slowly, as most loading screens do.
This is what I have.

dots = ('............')
for x in dots:
sys.stdout.write(x)
sys.stdout.flush()
time.sleep(0.2)

I cannot for the life of me figure out how to get the dots to appear on the same line as "Loading". Every way that I have attempted, the word "Loading" appears and then the dots appear on the next line.

John Gordon 04-05-2013 02:31 PM

Re: Typing letters slowly using sys
 
In <44fa9565-c6cd-4a46-ad28-97417b403444@googlegroups.com> mattgraves7@gmail.com writes:

> dots = ('............')
> for x in dots:
> sys.stdout.write(x)
> sys.stdout.flush()
> time.sleep(0.2)
>
> I cannot for the life of me figure out how to get the dots to appear on
> the same line as "Loading". Every way that I have attempted, the word
> "Loading" appears and then the dots appear on the next line.


How are you printing the "Loading" text? (It would have helped a lot to
show us that code.)

--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"


Grant Edwards 04-05-2013 02:50 PM

Re: Typing letters slowly using sys
 
On 2013-04-05, mattgraves7@gmail.com <mattgraves7@gmail.com> wrote:

> dots = ('............')
> for x in dots:
> sys.stdout.write(x)
> sys.stdout.flush()
> time.sleep(0.2)


That works just fine for me using Python 2.4, 2.6, 2.7 and 3.2.

--
Grant Edwards grant.b.edwards Yow! Is it 1974? What's
at for SUPPER? Can I spend
gmail.com my COLLEGE FUND in one
wild afternoon??

Mitya Sirenef 04-05-2013 02:52 PM

Re: Typing letters slowly using sys
 
On 04/05/2013 10:04 AM, mattgraves7@gmail.com wrote:
> I am using sys to give the effect that I am typing letters slowly. Basically what I want to have happen is have it show "Loading......" with the word loading appearing instantly and then the periods appearing slowly, as most loading screens do.
> This is what I have.
>
> dots = ('............')
> for x in dots:
> sys.stdout.write(x)
> sys.stdout.flush()
> time.sleep(0.2)
>
> I cannot for the life of me figure out how to get the dots to appear on the same line as "Loading". Every way that I have attempted, the word "Loading" appears and then the dots appear on the next line.


If you're printing in 2.x, you can do:

print "Loading",

in 3.x,

print("Loading", end='')

-m

--
Lark's Tongue Guide to Python: http://lightbird.net/larks/


Matt 04-05-2013 03:10 PM

Re: Typing letters slowly using sys
 
On Friday, April 5, 2013 10:04:49 AM UTC-4, Matt wrote:
> I am using sys to give the effect that I am typing letters slowly. Basically what I want to have happen is have it show "Loading......" with the word loading appearing instantly and then the periods appearing slowly, as most loading screens do.
>
> This is what I have.
>
>
>
> dots = ('............')
>
> for x in dots:
>
> sys.stdout.write(x)
>
> sys.stdout.flush()
>
> time.sleep(0.2)
>
>
>
> I cannot for the life of me figure out how to get the dots to appear on the same line as "Loading". Every way that I have attempted, the word "Loading" appears and then the dots appear on the next line.


Sorry guys, I may have not been clear. The part I pasted does work, but I cannot figure out how to get that to print after the word "Loading". So it will instantly print "Loading", and then the "..........." will appear slowly

John Gordon 04-05-2013 03:14 PM

Re: Typing letters slowly using sys
 
In <b7680abc-4566-4aad-9426-9d80881899bd@googlegroups.com> Matt <mattgraves7@gmail.com> writes:

> Sorry guys, I may have not been clear. The part I pasted does work, but
> I cannot figure out how to get that to print after the word "Loading". So
> it will instantly print "Loading", and then the "..........." will appear
> slowly


Have you tried:

sys.stdout.write('Loading')
sys.stdout.flush()

--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"



All times are GMT. The time now is 12:31 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.