psychopy.org | Reference | Downloads | Github

Set text and set image

URL of experiment: https://pavlovia.org/jaycbcs1/esst_

Description of the problem: text and image is not appearing on screen online

I am using .setImage and goXO1.setText(‘X’) and also tried goXO1.text = ‘X’

but not working

any suggestion…

Thanks in advance…

In what way is it not working? Please show your code component and the routine so we can see the relative positions.

it is not showing text and image that i am setting in the code section.

I added these inline in the begin routine
as this same code is working in offiline without giving any error.

I think it need some modification for online running as in js script.

if stimXO1[trialN] == 1:
goXO1.setText(‘X’)
else:
goXO1.setText(‘O’)

if GNG1[trialN] == 1:
#print(“trial number”,trialN)
#print(“image”, eFace[emoId1[trialN]])
stop1.setImage(eFace[int(emoId1[int(trialN)]]))

Thanks

Have you tried print(trialN) etc?

Personally I’ve found that .text= works better than.setText() but I think that both should work and you say you’ve tried both .

You have some commented out print commands . They have , where U would expect +

Did the confirm that your image is correct?

Are you getting any error messages?

Is there anything else that might be hiding the images?

Hello Thanks for reply

i tried both but letter not appearing.

print i tried in offline, where it worked…

is this possible to see online, please let me know.

There is no error message, program is running smoothly.

Thank You

You really should show us the JavaScript version as well then.

Use Developer Tools (Ctl-Shift-I in Windows/Chrome, Cmd-Opt-J in Mac/Chrome, F12 in IE/Edge, Ctrl-Shift-J in Windows/Safari, Ctrl-Opt-J in Mac/Safari) to view errors via the browser console if you aren’t getting sufficient information from PsychoPy. You can add print(var) (which translates to console.log(var); ) to check the value of a variable var at a particular point. N.B. There’s nothing to stop your participants doing this which may give them access to trial variables you may be loading from Excel and allow cheating on experiments with a performance based reward.

It seems code written in Begin Routine is not visible in js code online.

Thanks a lot @wakecarter for this information.

sorry to say but i am unable to see code of begin routine section in .js online file and also in web IDE.

Thanks for your support.

Have you made your experiment in Builder?

If so, please could you show screen shots of your code components?

Now some issue resolved as i saved images as image.jpg and in online html.resources saved as image.jpg.jpg.

now i am using this code stop1.setImage(None) which was working offline but now it seems problem here.

in some trials i am setting an image but on some trials i don’t need image.

any suggestion regarding this would be helpful.

Thank You

To hide an image use stop1.setAutoDraw(False)

Check the syntax in my crib sheet