[visionegg] falling out of a go() loop which is set to run_forever so that asecond go() loop can be allowed to run

  • From: Mark Tovey <getmark@xxxxxxxxxxxx>
  • To: "visionegg@xxxxxxxxxxxxx" <visionegg@xxxxxxxxxxxxx>
  • Date: Wed, 23 Jul 2003 22:17:00 -0400

Hi Andrew,

I'm preparing stimuli for a magnet which requests the next stimulus via a
mouse click.

My basic question is as follows:

How do I quit prematurely out of a go() loop (say, as a result of a mouse
button press), without exiting the VisionEgg script entirely?

Here's a simple example of what I mean.

Let's say I had three Presentations set up, call them p, q, and r -- all in
run_forever mode, each something like:

p = Presentation(go_duration=('forever',), viewports=[view],
brackets_viewport], handle_event_callbacks=handle_event_callbacks)

q = Presentation(go_duration=('forever',), viewports=[view],
brackets_viewport], handle_event_callbacks=handle_event_callbacks)

r = Presentation(go_duration=('forever',), viewports=[view],
brackets_viewport], handle_event_callbacks=handle_event_callbacks)

They only differ in their controllers.  Their controllers cause them to
display stimuli in different positions and sizes.

I'd like to run them in sequence, like so,


p.go()
q.go()
r.go()

with q being run after p has has received a signal to quit (in my case, via
a mouse click), and r being run after q has received a signal to quit.

I've got handlers set up like so:

handle_event_callbacks = [(pygame.locals.QUIT, quit),
                          (pygame.locals.MOUSEBUTTONDOWN,mouse_button_down),
                          (pygame.locals.MOUSEBUTTONUP, mouse_button_up),
                          (pygame.locals.KEYDOWN, keydown)]

So that I can do the following:

def mouse_button_down(event):
        if event.button == 1:
            # what should go here? (what I want is to exit the current go)

Here's the question -- how can I gracefully drop out of the *current* go
loop when the mouse button is pressed (so that I can move on to the next
one), regardless of whether that go() loop is p.go() or q.go()?

Second question: I'm also wondering if there are timing (or other) issues in
organizing my stimulus presentation in this way (is it better to simply have
one main loop, rather than a number of loops in sequence)?

Thanks so much!

Mark

-- 

Mark Tovey
Ph.D. Student, Cognitive Science, Carleton University

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

Other related posts:

  • » [visionegg] falling out of a go() loop which is set to run_forever so that asecond go() loop can be allowed to run