Setting a background that is an image
Hi Guys,
I am trying to edit a small experiment and am not really familiar with this program.
In the beginning of the code we have a code set background "white". How could I do this so that I set an image there instead? Additionally, I would like to have it switching every couple of questions. It would look like this:
Which animal do you prefer (2 pictures in different places to choose)
What food do you prefer?
Which clothing would you rather wear?
etc...
Would be grateful for any responses!
Comments
Hi Pain,
Welcome to the forum!
What you describe seems absolutely possible, and it could be achieved with multiple methods depending on the exact workings of your experiment.
The most straightforward option would be to use
sketchpaditems to present your stimuli (questions) on which you insert a background image. The image can be changed after every X amount of trials, depending on the specific. See the documentation for a better description:However, in the example you provide it seems that you want participants to choose between two pictures? If you want to use clickable pictures it might be a solution to use
formsinstead ofsketchpads. Check the documentation what is possible or this recent forum post for more inpsiration:Bottom line, it is certainly possible but we need a bit more information on what you have tried so far and what it exactly is that you want to create.
Best,
Laurent
Thank you!
I have actually been able to figure this out by using bgroung_image = exp.get_file('materials/house.jpg')
+
my_canvas.image(bgroung_image, False, 0, 0), with image sized to the screen resolution. Then, while in loop, it is easy to change them as I wish.
Now I have a different dilemma, which is changing a cursor. The same idea as before, it should change along with the background - for example to .png of a shooting gun, or to a "+" sign or whatever.
Is it possible as well?
Thank you for taking your time to help me, I really appreciate it!
Hi again,
Great!
If i'm not mistaken the cursor is being drawn by your operating system and is therefore difficult to change with OpenSesame. You could try and see if you can manually change the cursor, but then i can't think of a method where you would be able to vary it. Perhaps @sebastiaan has an solution?
Exactly, the mouse cursor is handled by the operating system. If you want to draw your own mouse cursor, you have to hide the actual cursor (it is hidden by default in OpenSesame) and then draw your own cursor onto a
canvas. This is actually the example for the documentation of themouseobject.Let's say that you have two files in the file pool:
background.png, to be used for the background image, andcursor.png, to be used for the cursor image. Then you could do something like this:Check out SigmundAI.eu for our OpenSesame AI assistant!