| Reference | Downloads | Github

Drawing line as response

Hi, sorry for my bad english, i will put a french version below

Hello, I would like to create an experience on psychopy, I must briefly present a square that contains a vertical line then this square disappears and will appear in its place a 2nd square without the vertical line, the participant must draw a line on this 2nd square. I used the “brush” tool but the problem is that it is not possible to draw on the square, I would like to know if someone can tell me how to put it in the background? I tried to change the opacity ect but nothing works.

Bonjour, je souhaiterai créer une expérience sur psychopy, ou je dois présenter brièvement un carré qui contient une ligne verticale ensuite ce carré disparaît et apparaîtra à sa place un 2e carré sans la ligne verticale, le participant doit dessiner sur ce 2e carré une ligne. j’ai utilisé l’outil “brush” mais le problème c’est que il n’est pas possible de dessiner sur le carré, je souhaiterais savoir si quelqu’un peut m’indiquer comment faire pour le mettre au second plan? j’ai essayé de modifier l’opacité ect mais rien ne marche.


Hi, the order of components is important. They are drawn in order from top to bottom. So put the brush component below the rectangle component. That way, the rectangle gets drawn first (i.e. in the background) and then the brush will be drawn on top of it. You can change the order of components by right-clicking on their icons.

thanks for your response but i tried this and its doesn’t worked :frowning: , the rectangle component is in .png , i dont know if its important

It works for me. What you need to do is create the smallest possible example that reproduces the issue and post it here.

Also note that you haven’t yet fully described the issue: “it is not possible to draw on the square” doesn’t tell us exactly what is wrong. e.g. Can you draw elsewhere on the screen, but just not on the square?

Yes, i can’t draw on the square but i can elsewhere on the screen, i uploaded a small example here

untitled.psyexp (7.1 KB)
Thanks for your help

As stated above, you have the image_2 component below your brush component. In the drawing order, that means image_2 will be drawn over the brush stroke, making the brush stroke invisible behind it. Simply swap their order and try again.

sorry its not working for me. i think there is problem with png. files.

OK, I have no idea why this happens, but in your particular experiment, it can be fixed as follows:

  • Break your trial into two consecutive routines.
  • In the first one, just have the first image, set to display for a fixed period of time.
  • In the second routine, have the second image (at the top), followed by the brush component (at the bottom), both set to come on at t = 0.

This sequence of events, even though spread across two routines, will be identical to your intended sequence.

I don’t know why there is some weird interaction with the drawing order in your original layout, but it works when split up like this.

The two-routine layout also seems to allow the mouse pointer to not be visible when the first image is shown during the first routine: I guess this may be useful to you, to stop subjects just putting the mouse pointer exactly on the location of the line and starting to draw from there when the image changes.

Lastly, it is always a good idea to put the full name of the image file in the image components. I actually didn’t know it was possible for Builder to find an image file if it doesn’t have its extension (in this case .png) specified, but weirdly, it seems to work here.

@jon: you might want to look at the .psyexp file above. The drawing order of the brush and the second image is wrong, but correcting it so that the brush component appears below the second image component has no effect: drawing happens behind the image, regardless of the specified order. Splitting the two image components across routines fixes the issue. I can’t see from the generated .py code why this would happen - everything seems to be correct. So I wonder if this is something internal to the brush component code, or to the way that the autodraw ordering is handled?