Text component in Pavlovia showing properties

URL of experiment: untitled [PsychoPy]

Description of the problem: Text component is being populated from a sequential loop with an excel sheet with different text, and $text as the content. Online it is showing as a full description of the text component (e.g., name = textStim, details about size, etc.) instead of the text itself

This suggests that you are using text as the name of a text component and also a variable for the contents. Try changing one of those… probably the contents.

I didn’t have any components named just “text” but I did reuse “text” as the value across multiple components in separate routines. I’ve gone through and renamed them text_4, 5, 6, etc. and also added code components to component.setText(text_4) because they weren’t functioning without that. However, now some routines are saying that text_30 can’t be found, even though I’ve used the exact same procedure - any thoughts?

It’s absolutely fine to use the same variable to contain different strings (contents) at different points in the study.

However, text, text_2, text_3, etc are the default names for the text components so I wouldn’t recommend using them for the strings.

msg is often used for the text string.

Do you need to set the text in code components? If so, then I typically use text_2.text = msg rather than text_2.setText(msg). I can’t remember if there’s a reason for this.

I don’t need to set them in code components, I am using a loop in theory but it was still just presenting the descriptions of the components as above, unless I added a code component. I would normally just set them in builder. But now even with a code component I get the error that the contents can’t be found

I just updated to the “text_2.text = msg” approach, but still get the message that “msg” can’t be found (see below). I have triple checked all naming and in the code there’s no difference to the earlier routines of when msg is called

  • ReferenceError: Can’t find variable: phase2_instrClosed_msg

Please could you show where you define phase2_instrClosed_msg?

In an excel spreadsheet, I’ve just made the full GitLab available if that helps? - Cate MacColl / E4version7 · GitLab

It’s still private. You could just upload your psyexp file here.

If you don’t need to set the values in code components then don’t. I sometimes use code components if there are functions used when building the text that need to be translated to JS.

Apologies - I’ve attached the .psyexp here. I wouldn’t usually specify them in code, but it didn’t work unless I added the code component. There is now a problem in the experiment itself where it is not accurately calling from a spreadsheet to set the response option (which seems like the same problem - it’s just not reading from spreadsheets in the loops when I upload it to Pavlovia)

E4version8.psyexp (409.7 KB)

In this case in phase2 I set images to either box1, box2, box3 or box4 with an inner loop that sets these values to colourA or colourB, and then an outer loop that sets colourA and colourB to either “red.png” or “blue.png” for counterbalancing purposes. I’ve tried in the inner loop specifying directly to red and blue.pngs and that works, and I’ve put a test trial inside the outer loop (but outside the inner) that sets an image to colourA, and that works too. It is something about the double loop that seems to not be working

I recommend moving code components to the tops of their routines.

If you have Begin Routine code, it can’t affect a component above it.

However, I would start by removing all the code that’s duplicating the components being set each repeat.

You could make your code more efficient by reusing routines. For example, Are randInstr and phase2Closed the same? If you changed text_17 in E4_randinstr.xlsx to msg then you could use phase2Closed.

However, I would also change image.

Use simple terms for variables, since they may already be in use by PsychoPy. Variable names to avoid are: class, core, final, image, index, Length, list, Object, Number, round, sound, Symbol, t, thisTrial, trials, util, visual.

Hi Wakefield, I have created a new file to replicate the problem of my Pavlovia experiment not reading excel in loops, and can’t identify why this isn’t working. The inner loop works in isolation, and the outer loop can independently specify images, but the combination of both results in a “resource unknown” error. I haven’t added any code components.



testOuterLoop.xlsx (8.7 KB)
testInnerLoop.xlsx (8.7 KB)
replication.psyexp (13.9 KB)

Maybe in concentric loops you need top specify the resources in Experiment Settings / Online / Additional resources.

Unfortunately, I’ve tried adding them in additional resources as well as changing back to an older version of PsychoPy, see error attached. I’ve deleted and reuploaded them, and made sure to create all the excel sheets from scratch.

Check in an incognito tab.

Same problem

The problem is that when you set the image as $testImage you are setting it as either “colourA” or “colourB” as strings not as variables.

Here’s some code:

if testImage == 'colourA':
    thisImage = colourA
else:    
    thisImage = colourB

In the attached psyexp file I also move the code component to the top and added thisImage = ‘’ in Begin Experiment as well as setting the image to present $thisImage

replication.psyexp (14.2 KB)

That’s fantastic - thank you! Is it surprising that it’s reading as a string? I’ve used this approach in previous versions of PsychoPy without a problem…

Would the problem with text components be related if they are also in a concentric loop, or should they be fine with a string?

I don’t know if your approach used to work in earlier versions, but there have been variations over the years on how lists, for example, get read from spreadsheets. I suspect that the concentric loop issue is because that’s when you started using the inner loop to refer to a column in the outer loop.