OS (e.g. Win10): Win10
PsychoPy version (e.g. 1.84.x): 2024.1.5 vs 2024.2.4
Standard Standalone? (y/n) If not then what?: yes
What are you trying to achieve?:
I coded several tasks in the 2024.1.5 version, and I shared these tasks with a colleague using the 2024.2.4 version. The tasks do not work anymore due to an error…
In the task, I had a code element named “language” which is launched during the “Begin experiment”. This code contains the instructions in both french and english:
# Check if expInfo exists and create the language variable
if 'expInfo' not in globals():
expInfo = {}
# Set default values to English if it is missing from expInfo keys
if 'language' not in expInfo:
expInfo['language'] = 'English'
# Create the language variable
language = expInfo.get('language')
# Define instructions based on the selected language
if language == "English":
instructions = {
'Text_instructions': (
"Welcome to the task\n\nPress the space bar to continue"
),
'Text_end_task': (
"This task is now over.\n\nThank you!\n\nPress the space bar to continue"
)
}
else:
instructions = {
'Text_instructions': (
"Bienvenue dans la tâche\n\n\Appuyez sur la barre d'espace pour commencer"
),
'Text_end_task': (
"Cette tâche est maintenant terminée.\n\nMerci !\n\nAppuyez sur la barre d'espace pour continuer"
)
}
In another routine, I have a code element pointing to the “language”, and to a Text element to show the text according to the language of the participant (by default, it is in english):
# Set the text for the first set of instructions
InstructionsText.setText(instructions['Text_instructions'])
It works perfectly in 2024.1.5 version, but not in the 2024.2.4.
What specifically went wrong when you tried that?:
I have this error when the task is launched in the 2024.2.4:
InstructionsText.setText(instructions (‘Text_instructions’]).
TypeError: ‘Routine’ object is not subscriptable
I am not sure to understand this error. But it seems that the new version changed the way the routine is handled.
I have created a small experiment with the elements to help reproducing this error:
error.psyexp (23.3 KB)
.
My question is:
Is there a solution to make it work in the 2024.2.4 version?