How can I align a TextBox2 stimulus to be in the center of a textbox? I tried changing the alignment
attribute, but it had no effect (for Psychopy v20201.1.3). Here is my example code:
from psychopy import visual, logging
from psychopy.hardware import keyboard
win = visual.Window(
size=[1536, 864], fullscr=True, screen=0,
winType='pyglet', allowGUI=False, allowStencil=False,
monitor='testMonitor', color=[0,0,0], colorSpace='rgb',
blendMode='avg', useFBO=True,
units='height')
textbox = visual.TextBox2(
win, text='Hallo', font='Arial',
pos=(0, 0), letterHeight=0.05,
size=(0.9, 0.2), borderWidth=2.0,
color='white', colorSpace='rgb',
opacity=1,
bold=False, italic=False,
lineSpacing=1.0,
padding=None,
anchor='center',
fillColor=None, borderColor='blue',
flipHoriz=False, flipVert=False,
editable=False,
name='instr1_textbox',
autoLog=True,
)
key_resp = keyboard.Keyboard()
pos = [(0,0), (0.2, 0.2), (-0.2, 0.2), (-0.2, -0.2), (0.2, -0.2)]
aligns = ['center', 'left']
textbox.autoDraw = True
for this_pos in pos:
for this_align in aligns:
textbox.pos=this_pos
textbox.alignment=this_align
textbox.text=str(this_pos) + ' ' + this_align
while not key_resp.getKeys():
win.flip()