Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23131

PsychoPy adding Spaces to TextStim

$
0
0
        while True:            #win.flip()            keys = event.getKeys(keyList = ['space', 'return', 'backspace','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'])            if any(key in keys for key in ['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']):                textbox.text += keys[0]            if 'return' in keys:                break            for key in keys:                if key == 'backspace':  # Handle backspace                    textbox.text = textbox.text[:-1]                    textbox.draw()                    print('backspace')                elif key == 'space':                    textbox.text += ''                    print(key)                else:                    if len(str(textbox.text)) % 75 == 0:                        textbox.text += '\n'                    else:                        textbox.text = textbox.text[:-1]                        textbox.text += key                    print('input', textbox.text)                    textbox.draw()                welcome_stimuli[stimuli_order[i]].draw()                win.flip() 

Hi, I have a code that allows participants to input text into PsychoPy with the Keyboard in real time. It works well but when I want it to add spaces between the letters it adds a line break instead. I tried several ways of adding spaces but they all seem to just end up in line breaks and simulate \n. Does someone know how to add spaces to a visual TextStim?


Viewing all articles
Browse latest Browse all 23131

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>