[Tutor] time delay in graphics loop

Lloyd Kvam lkvam@venix.com
Fri, 23 Nov 2001 10:11:25 -0500


This is a multi-part message in MIME format.
--------------040005060607060308080902
Content-Type: text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding: 7bit

Sorry for the delay.  I have not been using Tkinter, and my Python 
configuration for Tkinter was not working.  It took some time to get 
that fixed, and then the Thanksgiving Day Holiday intervened.

When I put time time.sleep(1) in the "y loop", the program draws the 
circles after about 13 seconds by my watch.  This is close to what we 
would expect: (12 * 1) second delay.

Moving the 1 second sleep into the "x loop" should give us (12 * 16 * 1) 
seconds of delay = 192 seconds.  When I run it here, I get 194 seconds 
by my watch.

With no sleep, the screen comes up very quickly on my system, within a 
second.

I am running Win NT 4.  My desktop experience is primarily Windows and 
Linux.  I would expect similar results on Linux.  I've enclosed my copy 
of the script.  If your results are radically different, I would expect 
some kind of problem with your computer setup.

Jane Handcock wrote:

> Lloyd,
> 
> Thank you for your reply, but surely if I put time.sleep(1) in the outer
> loop it should work quite quickly??
> ie
> ....
> for y in range(12):
> 	time.sleep(1)
>       for x in range(16):
>           circle(x*40+20,y*40+20,20)
> ....
> 
> Jane
> 
> -----Original Message-----
> From: Lloyd Kvam [mailto:lkvam@venix.com]
> Sent: 19 November 2001 19:54
> To: Jane Handcock
> Cc: tutor@python.org
> Subject: Re: [Tutor] time delay in graphics loop
> 
> 
> When you put the sleep inside the y loop, you sleep for 5 seconds
> everytime through the loop, = 60 seconds plus the other processing time.
> 
> Within x it is sleeping 12 * 16 * 5 which is a lot of seconds.
> presumably, it is not hung, just much slower than your patience level.
> 
> Jane Handcock wrote:
> 
> 
>>Hi
>>
>>I have just started to use Python and am working through the LiveWires
>>Python Course.
>>Can anyone explain why the time delay in the code below works fine (before
>>the graphics window is filled with blue circles), but the program hangs if
>>
> I
> 
>>put the line time.sleep(1) inside the y or x loops?
>>
>>
>>from livewires import *
>>import time
>>begin_graphics()
>>set_colour(Colour.blue)
>>time.sleep(5)
>>for y in range(12):
>>    for x in range(16):
>>        circle(x*40+20,y*40+20,20)
>>end_graphics
>>
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor@python.org
>>http://mail.python.org/mailman/listinfo/tutor
>>
>>
>>
> 
> 
> --
> Lloyd Kvam
> Venix Corp.
> 1 Court Street, Suite 378
> Lebanon, NH 03766-1358
> 
> voice:
> 603-443-6155
> fax:
> 801-459-9582
> 
> 
> 


-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice: 
603-443-6155
fax: 
801-459-9582

--------------040005060607060308080902
Content-Type: text/plain;
 name="live_circle.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="live_circle.py"

from livewires import *
import time
begin_graphics()
set_colour(Colour.blue)
for y in range(12):
    for x in range(16):
        time.sleep(1)
        circle(x*40+20,y*40+20,20)
end_graphics

--------------040005060607060308080902--