[visionegg] Re: Exiting a While Loop

  • From: Andrew Straw <astraw@xxxxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Tue, 31 Jul 2007 15:48:12 -0700

Dear Jeff,

If you're not dealing with events in p.go(), they will very likely never
be seen by your code. Check the mouseTarget.py demo for an example of
setting up callbacks to deal with events within the go() loop.

Let us know if you're still stuck.

-Andrew

Maher, Jeffrey wrote:
> Hello all,
>  
> Yes I know this is a repeat to my previous question, and I apologize for 
> that.  I have made some progress in the code, now I need is a slight bit of 
> debugging and advice.
>  
> As a reminder, my problem is that I could not get the while loop to terminate 
> prior to the set value being reached.
>  
> Previously I was not able to get the code for trapping a keypress into the 
> while loop, and while now that I have, it seems unable to read the code and 
> simply jumps over it to the other conditions of the while loop. In the code 
> below, it appears as though the for loop is completely ignored.
>  
> If I try bumping the p.go and i=i+1 an indent over, I get random number of 
> stimulus presentations, and the the keypress seeems to (MAYBE) make a 
> difference. I have also tried using an else statement, but that seemed to 
> reset the value of i and again produce a random number of time the stimulus 
> is presented.
>  
> Heres the code:
>  
>       
>         i=0
>         while i!=eval(self.number.get()):
>             for event in pygame.event.get():
>                 if event.type == pygame.locals.KEYDOWN:
>                     if event.key == pygame.locals.K_UP:
>                         i=self.number.get()
>         
>             p.go()
>             i=i+1
> 
>  
> 
> Any suggestions would be much appreciated.
> 
> -Jeff
> 
> 
> ====================================
> The Vision Egg mailing list
> Archives: //www.freelists.org/archives/visionegg
> Website: http://www.visionegg.org/mailinglist.html

======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: