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

Ah ha! This works brilliantly on the test program. However, my actual experiment program has multiple go loops triggered by different keystrokes (over 20). I couldn't get the constant controller to update the during_go_value from a keystroke trigger (during the run forever loop). I couldn't get the constant controller to only set between_go_value and let me assign viewports from a keystroke trigger. Nor could I get constant controller to respond to any eval_frequency setting other than transitions or every frame (ie if I told it only to evaluate not_during_go, the whole thing stopped working and my original problem reoccured). I also to make a plain controller (vs constant or function) that evaluated not during go, and that didn't work. Sad!

Should I try an Encapsulated Controller?

On Sunday, Feb 1, 2004, at 02:53 US/Pacific, Andrew Straw wrote:

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: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html


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

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

Other related posts: