[visionegg] Re: go loops and run_forever (was sorry to bother you again...)

  • From: "Andrew Straw" <andrew.straw@xxxxxxxxxxxxxxx>
  • To: visionegg@xxxxxxxxxxxxx
  • Date: Sun, 1 Feb 2004 21:23:32 +1030 (CST)

Hi Jordanna,

Basically, you have to restore p.parameters.viewports to [viewporta] when
the go loop is over.  I haven't tested this, but it would be something
like:

p.add_controller( p,
    'viewports',
    ConstantController(
        during_go_value = [viewportb],
        between_go_value = [viewporta],
        eval_frequency = Controller.TRANSITIONS ))

This controller sets the value of p.parameters.viewports on transitions in
and out of go loops.  It should do exactly what you want.

> I can't figure out how to define finite go loops inside of a run
> forever loop. Previously Andrew said I should only be using one
> presentation object, but I don't seem to be able to get it working.
> Here is a test program I've written (relevant bits). Does anybody have
> sample code I can look at?
>
> Problem: when I hit the 'a' key, the presentation changes to displaying
> the viewport b stimulus, but does not return to the viewport a stimulus
> when finished.
>
> #####################################################
> # design 'handling' of run forever loop
> #####################################################
>
> global p
>
> f=open('debug_file.txt','w')
> def keydown(event):
>       if event.key==pygame.locals.K_q:
>               p.parameters.enter_go_loop = 0
>               p.parameters.quit = True
>       elif event.key==pygame.locals.K_a:
>               p.set( go_duration=(5.0,'seconds'),
>                                viewports=[viewportb],
>                                enter_go_loop=1)
>
> handle_event_callbacks = [(pygame.locals.KEYDOWN,keydown)]
>
>
> ##########################################################
> # create presentation object for outside run forever loop
> ##########################################################
> p = Presentation(viewports=[viewporta],handle_event_callbacks =
> handle_event_callbacks)
>
>
> ###############
> # run it !!!  #
> ###############
>
> p.run_forever()
>
> ======================================
> 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: