TextStim - how to set alignment?

Quick Question: I am trying to display left aligned text using Builder TextStim,
but it all appears to be entered around the pos parameter.
In coder you’d use the alignHoriz parameter for this but this does not appear to be there in builder. WHat’s the best way to display different text elements (i.e. different TextStim objects) of variable length in a list, i.e. orderly one under the other, all left aligned?

THanks
Marc

@Marc_Buehner, if you want to change the alignment of the text component bounding box, you can set the attribute at the beginning of a routine in a code component using text.alignHoriz = 'left'. Note, this does not align the text within the bounding box, only where the box lays on the position coordinates.

HI there and thanks.
Yes, I have since realised that.
The question is: if use a code component in builder, would I need to have it in the ‘every frame’ tab? Because the ‘start of routine’ code is executed BEFORE the stims are defined and that would lead to errors?
And if it is every frame, would that incur performance issues?

Thanks

When are you creating your text components? If you are using the Builder to create your text components, then they will be defined before the routine begins, so it should be ok.

HI dvBridges – thanks. Yes, routine actually works! I must have mis-read the code!

For those that might be reading this “alignHoriz” was deprecated for text stimuli in PsychoPy 3.3. Use “alignText” or “anchorHoriz” instead.

In 2022.1.0 (which will be releasing v soon!) we’ve sorted out anchoring and alignment for the TextBox component, so stuff like this will be much smoother :slight_smile: You’ll be able to set anchor to choose which point on the box is on the actual point indicated by the component’s position, as well as how the text is aligned within the box.

This is a recording of a demo which will be added to show how these parameters affect its appearance:

1 Like