Mouse and typed response checking not working

OS Windows 10
PsychoPy version v2021.1.2
Standard Standalone? (y/n) Yes
What are you trying to achieve?: Program a typed response task

What did you try to make it work?: Watched How to get typed responses in PsychoPy - YouTube and How to check if a typed response is 'correct' in PsychoPy - YouTube, and read through blog posts on similar issues.

What specifically went wrong when you tried that?:

I have two issues: 1) the Mouse functionality isn’t working and 2) my TextBox responses are not immediately accessible.

When I include the mouse component per the videos above, I get the following error message
Traceback (most recent call last): File "C:\Users\KUbsadmin\Desktop\test\test_lastrun.py", line 490, in <module> if obj.contains(mouse): AttributeError: 'list' object has no attribute 'contains'

I put the correct clickable stimulus (endButton) per the videos, so I don’t think that’s the issue.

If I remove that and just use a timed routine termination, I can’t test whether the typed response is correct, which I need in order to terminate the loop and move on. I ask the participant to type in a three-digit integer, so I when I try the following code:

if int(textbox.text) == corrAns: trials.finished = 1

I get the following error message:
Traceback (most recent call last): File "C:\Users\KUbsadmin\Desktop\test\test_lastrun.py", line 496, in <module> if int(textbox.text) == corrAns: ValueError: invalid literal for int() with base 10: ''

Which makes me think the textbox.text response is not being stored.

Any help with this would be greatly appreciated!! @Becca I think you made the original videos so I thought I’d tag you and get your opinion!

The fix for this was included in 2021.1.3, so if you update to the newest version this should be fixed :slight_smile:

Hello,

Thank you for your help! The mouse issue is definitely fixed, but I’m still unable to check typed responses using a textbox.

When I try to convert the textbox.text output to an integer to check if the correct response was entered, I get the following response:
Traceback (most recent call last): File "C:\Users\KUbsadmin\Desktop\test\test_lastrun.py", line 496, in <module> if int(textbox.text) == corrAns: ValueError: invalid literal for int() with base 10: ''

I don’t think the input in the textbox object is being stored to be immediately accessible within the program; however, it does get saved in the datafile at least.

How about only converting the text to an integer (assuming you can’t alternatively convert corrAns to a string) once you’ve checked it exists?

Before checking if the contents match the answer, you should check if there are any contents. At the moment, your check is failing because the textbox is empty when this code runs.

1 Like