Howdy, Stranger!

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

Supported by

Shrink/enlarge image based on given response

edited November 2017 in OpenSesame

Hi all,

I'm programming an approach-avoid task using inline scripts in opensesame.
Participants have to sort portrait and landscape images by moving the mouse to the top or bottom of the screen.
For mousetracking I'm using mousetrap. I programmed it so that two invisible boxes are on the top and bottom of the screen. And in the middle of the screen the stimulus image is presented.

When someone moves the cursor to the top box (avoid) I want to shrink the picture, and when someone moves the cursor to the bottom box (approach) I want to enlarge the picture.

I can't seem to figure out a way to do this.

As of now the inline script (run phase), after the mousetrap item, looks like this:

response_canvas = canvas()

if var.response_mousetrap_response == "top_box":
    response_canvas.text("Image is supposed to get smaller now")
elif var.response_mousetrap_response == "bottom_box":
    response_canvas.text("Image is supposed to get larger now")

Does anyone know of a way to do this?


  • Hi Femke,

    Are you using a sketchpad to present the display? If so, then I would download the latest prerelease of OpenSesame 3.2, because it allows you to name and access the elements on a sketchpad. So, say that your image is called, 'my_image' and your sketchpad is called my_sketchpad, then you could increase the size of the image as follows:

    my_canvas = items['my_sketchpad'].canvas
    for scale in range(100, 200):
        my_canvas['my_image'].scale = .01*scale

    See also:


  • No, I'm using mostly canvas' via inline scripts. But I'll check out your suggestion though. Thanks!

  • Hi Sebastian,

    I have same question. And i tried the code(above), but didn't understand what to write instad of 'my_image'. Should i put my image list name in the block loop? When i put my image list name, i have an error 'KeyError 'image1.png''

    I'd appreciate it if you answered.


  • I found the answer to my question in another topic on the forum (Eduard's answer).

    Thanks OS.

Sign In or Register to comment.