| Reference | Downloads | Github

TextBox attributes

Hi all,

I am trying to program an experiment in which words are presented, very fast, with varying sizes and fonts. However, when I try to do this using TextStim, drawing the text stimulus is too slow and the timing of my experiment gets messed up. Based on what I read here, I thought using TextBox instead would be ideal. However, here I run into another problem:

Here is how I initially draw the textbox (with the exact text coming from another variable), and this works fine, also if I manually adapt the ‘font_size’:

stimtrain = [visual.TextBox(prefs.window, txt, font_size = 32, font_color = [1,1,1], size = (1,1), pos = (.0,-.1), grid_horz_justification = ‘center’, grid_vert_justification = ‘center’, autoLog = False) for txt in currtrain.framestoload]

However, when I then add this line of text:

originalsize = stimtrain[0].font_size

I get this error message:

Traceback (most recent call last):
File “C:\Documents and Settings\eegusr\Desktop\Annabel FPVS\facetaskpilot\EEG_fpvs_pilot_withcross_v2 (names).py”, line 511, in
originalsize = stimtrain[0].font_size
AttributeError: ‘TextBox’ object has no attribute ‘font_size’

I have tried it with other attributes (size, text…) and actually get the same error message. What am I doing wrong?

From the Psychopy API ( “TextBox attributes are never accessed directly; get* and set* methods are always used (this will be changed to use class properties in the future).”

So if you could change the attribute font_size, it would probably be through a setter method. However, judging from the documentation, TextBox doesn’t allow changing the attribute font_size after initialisation because I couldn’t find a method description on the documentation page.