[visionegg] Re: having trouble quiting run forever loops

  • From: "Andrew Straw" <andrew.straw@xxxxxxxxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Tue, 27 Jan 2004 14:13:07 +1030 (CST)

Hi Jordanna,

Only one instance of the Presentation class should be made at a time.  If
this isn't clear in the documentation, I should fix it-- there are many
things that the Presentation class does that assume complete control. 
This is probably what's causing the strange behavior you're experiencing.

Is it possible to change your program so that it all operates from within
one instance of the Prensentation class (p, for example)?

Cheers!
Andrew

> Hi,
>
> I am trying to atack go loops so that there is an outer runforever loop,
> and multiple inner go loops. I am using keystrokes as handle event
> callbacks to both quit the outer loop, and initiate inner finite go loops.
> If I execute the code, my run forever loop works fine, I hit escape and it
> quits just fine. If I execute the code and trigger the inner go loop, that
> loop plays just fine. Howver, once I trigger an inner loop, the escape key
> no longer quits the run forever loop. I can, however, still trigger teh
> inner go loop.
>
> Sample Code:
>
> ....define some state for run forever loop p
> ... define some state for inner go loop q
> ...make a presentaion abject for q
>
> global p
>
> def keydown(event):
>       if event.key==pygame.locals.K_ESCAPE:
>               p.parameters.quit=1
>       if event.ky==pygame.locals.k_a:
>               p.parameters.enter_go_loop=1
>               q.go()
>
> handle_event_callbacks = [(pygame.locals.KEYDOWN,keydown)]
>
> p =
> Presentation(go_duration=('forever',),viewports=[viewport],
>   handle_event_callbacks = handle_event_callbacks)
>
> p.run_forever()
>
> Has anyone else run up against this problem? Any suggestions?
>
> Thanks!
>
> Jordanna Sprayberry
======================================
The Vision Egg mailing list
Archives: //www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: