What are you trying to achieve?:
I’m trying to create an experiment on builder which will allow participants to type one word at a time then have the word they recalled moved to the upper right hand corner (essentially so they can see a list of all of the words they recalled).
Now that did work, as it should, but I want to change it so the participant can still see the words they typed earlier throughout the ‘routine’. How do I do that? If there’s a better way without the snippet, that’s fine too.
I’m new to python and PsychoPy so anything would probably be useful. haha Thank you!
No problem, you just need to change the (x, y) position of cornerText. The position coordinates are zero (0, 0) in the middle of the screen, so try (-.4, .4), play around with the positions to see what works. For the data, it depends on how you want the data saving. IF you want a new word in each column of your data file, add the following to the “End Routine” tab:
for index, word in enumerate(cornerText.text.split('\n')):
word = word.strip(' ')
if len(word):
thisExp.addData("word{}".format(index), word)
Try the attached, and see how it works. There were some other changes, removing the title of the word list (otherwise it gets saved in the data file as a word), switching the window units of the experiment to “height”, moving text from right to left, and resetting the cornerText on every trial.textFill.psyexp (8.5 KB)
#EachFrame
keys = event.getKeys()
if ‘escape’ in keys:
core.quit() # So you can quit
else:
if keys:
if keys[0] == ‘space’:
textFill += ’ ’ # Adds a space instead of ‘space’
elif keys[0] == ‘backspace’:
textFill = textFill[:-1] # Deletes
elif keys[0] in allLetters:
textFill+=keys[0] # Adds character to text if in alphabet.
screenText.setText(textFill) # Set new text on screen
#EndRoutine
for index, word in enumerate(cornerText.text.split(’\n’)):
word = word.strip(’ ')
if len(word):
thisExp.addData(“word{}”.format(index), word)
It is because you have not used the file I attached in the last post, which has some extra changes to the code component, since I changed the screen units to height. The position of the box is moving up or down because of:
This line resets the position of the text component whenever a new line is added. You need to do this to account for the fact that the text is center aligned, and if you do not change the position, the box grows from the center with new text, rather than from the top down. Try deleting that line and see what happens, then if you do not like it, use the attached.textFill.psyexp (8.5 KB)