Displaying Typed Words on Screen during a Routine

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).

What did you try to make it work?:
Since I’m using Builder, I tried to use the “InputText” snippet I found online: https://github.com/jacanterbury/PsychoPy-snippets

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!

Here is an example, adapted from Writen response - #2 by dvbridges.

See how this works, and change as need. textFill.psyexp (8.3 KB)

Thank you so much for your help! It worked, I’m just having two minor issues now.

Firstly, I want to have the list on the upper left hand corner. How would I change the code so it can do that?

Secondly, the responses aren’t being saved in the participant’s data file. How do I fix that?

Again, very much appreciated.

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)

Thank you so much again.

One last thing, I tried using the code but the word list, for some reason, keeps moving downward when a new word is entered. It’s strange?

Here’s the code in builder:

#BeginExperiment
import string
allLetters = list(string.ascii_lowercase)

#BeginRoutine
textFill = ‘’
cornerText.setText(’’)
cornerText.pos = [-.4, .4]

#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

    if keys[0] == 'return':
        cornerText.setText(cornerText.text + '\n' + screenText.text)
        textFill = ''
        screenText.setText(textFill)
        cornerText.setPos([.4, cornerText.pos[1] - (.056)])

#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:

cornerText.setPos([.4, cornerText.pos[1] - (.056)])

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)

Thank you so much for everything!