Left-align text stimuli within builder

Hey there,
My experiment’s text stimuli are left-aligned when I run it offline from psychopy builder, but when posted online the text is centered. Adding in strings of spaces to make the lines of text that are below each other the exact same length did not work. How can I left-align my text for the online version?

Hi @carlijn, yes the text is aligned ‘center’ by default in JS. If you want to change the alignment of your text component, add a code component, select “Both” for code type, and in the right panel, paste the following JS, where “text” is the name of your text component:

text.setAlignHoriz('left')
2 Likes

Thank you! @dvbridges
edit: responded too soon; have tried it in a few different ways but it didn’t work yet. neither when in ‘begin experiment,’ ‘begin routine,’ nor ‘each frame’. My text component is imported from an excel spreadsheet and updated each frame. Not sure what I’m missing here

Can you please share the URL for your task? You may just need to refresh the cache (CTRL+F5) on Windows.

thanks, it did work now!

1 Like

Hi,
I am having the same issue with my text alignment (my text component is imported from an excel spreadsheet). I tried to add a code component, but it does not seem to work. Also, the code type keeps defaulting to “Auto->JS.”

It doesn’t matter if it reverts to Auto so long as you don’t click in the left hand side.

Please could you clarify what isn’t working (and for the record I’m not yet able to left align locally but I can centre align online.

The text is still center aligned even when I add a code component to left align it.

We cannot know the problem if you don’t give more information/ show what you did.