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?
@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?
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.
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 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:
I found this announcement for TextBox anchoring, and I read in the Changelog that most visual elements since 2022.1. have an anchor option now.
However, I could not find a way to anchor my TextBox to specific pixel coordinates on the screen, by upper left corner, instead of the default option center.
Do you mean the upper left corner of the Textbox, or the upper left corner of the screen?
Anchoring the upper left corner of the Textbox to a position in pixels is just a case of setting its units to “pix” and its anchor to “top left”.
Defining a position relative to the top left corner of the screen is harder, but still very doable. PsychoPy indexes from the center, so (0, 0) will always be the middle of the screen. In “pix” units, you can set something’s position to be the top left corner by setting it to (-win.size[0]/2, win.size[1]/2) - in other words, (-half the width of the screen, +half the height of the screen). You can then add whatever pixel values you like to these coordinates to position it relative to the top left corner of the screen. If you additionally set the anchor of the Textbox to the “top left”, then this position will be where the top left corner of the Textbox sits.