Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] Set duration and change information on the slide due to keypress

edited November 2014 in OpenSesame

Hi everyone,
I would like to present two pictures next to each other on the same slide for two seconds (The material is in a list in a loop and works so far). However participants have the option of making the picture on the right disappear so that they only see the picture on the left for the full two seconds (explanation: the picture on the right is aversive and so propably want to make use of that option. However, I do not want them to press only to finish early, so they should still see the stimulus on the left for the full two seconds). So I either want the picture to dissappear or just to be covered by a blank picture when they press a key (e.g. the space key).
My problem:

  • if I use a sketchpad, I can set the duration, but it won't react to the keypress, since the slide is already fully loaded (as I understood it)
  • if I use a form_base, participants can change the slide by pressing a key, but it seems that I can not set a duration
  • if I use to separate sketchpads, the first one including both pictures, the second one only showing the picture on the left when the first slide was ended using the space key, I am afraid that the picture on the left will not be the same as on the first sketchpad since a new one will be taken from the loop.

I hope this does not sound too messy. It would be great if anyone knew a way around this problem and would be willing to share it with me :)

Thanks, Helen


  • edited 7:50AM

    Hi Helen,

    I suggest you draw your images directly to a canvas in an inline_script. It's not much more difficult than using a sketchpad, but gives you more freedom and control over it.
    I give you an example of the basic idea. Probably, you'll have to try a bit, until it looks just like you want it to. If you get lost, you can have a look on the documentation page (this is also where I copied most of the code from) or ask again here in the forum.

    Here the example:

    from openexp.canvas import canvas
    from openexp.keyboard import keyboard
    my_canvas = canvas(exp)
    my_keyboard = keyboard(exp)
    t0 = self.time()
    while (self.time() - t0) < 2000:
        response, timestamp = my_keyboard.get_key()
        if response == 'key which makes the right image disappear':

    Good luck!


  • thanks a lot for your answer. My remaining problem is that I would like to take the images from a list in a loop and somehow I cannot find how to do that. Instead, the get_file function will work with a singe picture, not a list of pictures in a loop...

  • edited 7:50AM


    You're right exp.get_file works only for single files. However, if you have your filenames in a list, you can simply loop over the list, read the current file, do with it whatever you want, and proceed then to the next file.
    Of course this requires that your list contains all filenames. Creating it can be a tiresome thing to do, so you can think about naming your files in a structured way (e.g. file1,file2,file3, ...), so that you only have to loop over the first till the last number of your filepool and can create the filename on the fly (filename = file + current_number)



Sign In or Register to comment.