Align Text Code Component not working

What are you trying to achieve?: Hello there! I have a quick question for beginners. I want to align my introduction text to the left. Right now it is entered around the pos parameter.

What did you try to make it work?: I searched for solutions in the forum and found this coding tip:
text.alignHoriz = ‘left’` . I defindet the Text that I wanted to be aligned, but Psychopy just gives out this Error message:

text.alignHoriz = ‘left’
AttributeError: ‘str’ object has no attribute ‘alignHoriz’
Experiment ended.

Now that I am new to coding and Python in general, I am not sure what went wrong or what I could do
to work it out. I would be greatful if someone could give me a hint on that :slight_smile:

Try changing the code to:

text.alignText='left'

where the first “text” is the name of your text component.

Hi there @Laura_Pissani!
Thank you for your replay! I tried it but it is not working :confused:
Psychopy is giving me this error message:

Text1.alignText=‘left’
NameError: name ‘Text1’ is not defined
Experiment ended.

What could be the problem?

It could be either the Caps, maybe your component is text1 and not Text1, or that you need to move your code component to the bottom/top of your routine.

See screenshots attached.

1 Like

Hi @Laura_Pissani,

thanks a lot! I had to move the coder component to the bottom, I didn’t know that this has such a impact.
Thanks a lot for your help! :smiley:

1 Like