我做了類似於你在後面描述的內容。也許這會有所幫助。首先,您有一些TextStim,以及一些預定義項:
instruction = psychopy.visual.TextStim(myWindow,color="white")
quitKeys = ['escape', 'esc']
ansKeys = ['space', 'return']
keyboardKeys = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
answer = ''
然後你有一個循環,在它裏面,你有這樣的事情 (我猜你也必須與外國字的東西你是顯示)
#Loop Starts Here>
instruction.setText(u':{0}'.format(answer))
instruction.draw()
myWindow.flip()
# get some keys.
for letter in (keyboardKeys):
if psychopy.event.getKeys([letter]):
answer += letter
if psychopy.event.getKeys(['backspace']):
answer = answer[:-1]
if psychopy.event.getKeys([quitKeys[0]]):
psychopy.core.quit()
if psychopy.event.getKeys([ansKeys[1]]): # enter is pressed
# and they have given their answer, So some code to check their answer
希望這有助於
只是畫一個矩形(例如,在需要的位置'ShapeStim'在編碼器或生成器'多邊形component')? –