Hello all,

I am currently working on an experiment. In short, I need the arrow stimulus. I don’t want to use pictures. What suggestions do you have about it?

I read that someone did the arrow stimulus as in the link below, but since I’m a beginner in python coding, could you please tell me how I can do this in a more simplified way?

They might not be the prettiest you could do this “<-- / -->”

Go to the demos menu, and from the “Coder” demos, select `shapes.py` and run it. It is a demo of creating arbitrary polygons. This is code from it that creates an arrow-shaped stimulus:

``````arrowVert = [(-0.4,0.05),(-0.4,-0.05),(-.2,-0.05),(-.2,-0.1),(0,0),(-.2,0.1),(-.2,0.05)]
arrow = ShapeStim(win, vertices=arrowVert, fillColor='darkred', size=.5, lineColor='red')
``````

If you’re not up for coding this yourself, you could probably just use the `Polygon` component in Builder. On its “basic” tab, select “Custom polygon” for the shape, and paste in the list of vertices given above, i.e:

``````[(-0.4, 0.05), (-0.4, -0.05), (-.2, -0.05), (-.2, -0.1), (0, 0), (-.2, 0.1), (-.2, 0.05)]
``````
1 Like

We need more detail to suggest how to help – “it doesn’t work” doesn’t tell us anything useful.

I also think image or polygon components are best for maximizing your control over how the arrow stimulus appears, so if images are not an option, I would opt for the polygon component.

However, if you wanted to use text components you could try the unicode character arrows:
U+2190 = ←
U+2191 = ↑
U+2192 = →
U+2193 = ↓

The text box of your text component will contain: ← or whichever arrow you want to display.

If you are setting the arrow in a different direction every repeat, the text component would be:
`\$VAR`
and column `VAR` in your trial spreadsheet would contain the unicode symbol: ←

I tested this in PsychoPy 2022.1.1 Builder and it seemed to work in both PsychoPy and PsychoJS.

3 Likes

I’m also searching for a method for creating an arrow using Polygon component. The vertices work perfect when I use PsychoPy locally (Thank you ), but when I converted to PsychJS and uploaded online, the arrow became a rectangle. It is a puzzle, I didn’t change the values, the shape changed .

It looks the option for custom polygon components doesn’t work fully in PsychoJS yet. bsclod’s solution in that thread might work for you.

• create your Polygon component as normal
• add a code component with the following in `begin routine` (code written in python, the auto-translate option will convert it to JS):
``````NAME_OF_COMPONENT.vertices = [LIST OF VERTICES]
``````

For example, if you named your Polygon component `arrow`, and want to use the vertices above, your code might be:

``````arrow.vertices = [(-0.4,0.05),(-0.4,-0.05),(-.2,-0.05),(-.2,-0.1),(0,0),(-.2,0.1),(-.2,0.05)]
``````

I tested this in PsychoPy 2022.2.4 builder and it works in both PsychoPy and PsychoJS.

1 Like