| Reference | Downloads | Github

Providing feedback before routine has ended

Version 1.85.6
Windows 10 Computer

I am trying to create an experiment using an image as my rating scale instead of the normal Psychopy rating scale. Currently, I am trying to create a marker using the polygon function, such that participants who hit ‘1’ on the keypress will see a circle over the 1 and if they hit 2 the circle will be over the 2 part of the scale etc. How should I go about doing this?

One method I tried was to create a code component, such that if the key press equaled 1 a polygon would be set to appear

if key_resp_2.keys == 1:
       polygon = visual.Rect(
       win=win, name='polygon',
       width=(0.5, 0.5)[0], height=(0.5, 0.5)[1],
       ori=0, pos=(0, 0),
       lineWidth=1, lineColor=[1,1,1], lineColorSpace='rgb',
       fillColor=[1,1,1], fillColorSpace='rgb',
       opacity=0, depth=-1.0, interpolate=True)

But this returned an error saying

“NameError: name ‘key_resp_2’ is not defined”

Does anyone have an idea on how to fix this?

  • The point of putting code in a code block is to preserve the indenting and formatting. It’s remarkably difficult to spot errors if you don’t do that.
  • You need to give us the entire error message, verbatim, and the piece of code it applies to. The message you gave us talks about key_resp, which does not exist in your code.
  • You also need to tell us when this code runs (i.e. what tab in the code component it lives in, and where that code component is in relationship to the keyboard component.