psychopy.org | Reference | Downloads | Github

Using TextBox instead of TextStim


#1

Following advice from https://stackoverflow.com/questions/36651509/psychopy-textstim-memory-leak-issue I’ve attempted to replace one of my TextStim stimuli with a TextBox (http://www.psychopy.org/api/visual/textbox.html)

I’ve replaced:

text_2 = visual.TextStim(win=win, name='text_2', text= 'c = 1\ndb = 2\nd = 3\neb = 4\ne = 5\nf = 6\ngb = 7\ng = 8\nab = 9 \na = 0 \nbb = t\nb = y' , font='Arial', pos=(0, 0), height=0.1, wrapWidth=None, ori=0, color='white', colorSpace='rgb', opacity=1, depth=-2.0); 

with:

text_2 = visual.TextBox(window=win, text = "c = 1\ndb = 2\nd = 3\neb = 4\ne = 5\nf = 6\ngb = 7\ng = 8\nab = 9 \na = 0 \nbb = t\nb = y", font_size = 18, font_color = [-1,-1,1], color_space = 'rgb', size = (1.8,.1), pos = (0.0,0.0), units = 'norm')



and I’ve received the following error message:

FreeType import Failed: dlsym(RTLD_DEFAULT, FT_Library_SetLcdFilterWeights): symbol not found
Traceback (most recent call last):
  File "/Users/sam/Downloads/AP_experiment_1/AP_exp_1_debugging.py", line 87, in <module>
    text_2 = visual.TextBox(window=win, text = "c = 1\ndb = 2\nd = 3\neb = 4\ne = 5\nf = 6\ngb = 7\ng = 8\nab = 9 \na = 0 \nbb = t\nb = y", font_size = 18, font_color = [-1,-1,1], color_space = 'rgb', size = (1.8,.1), pos = (0.0,0.0), units = 'norm')
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 119, in __call__
    obj = object.__getattribute__(self, '_resolve')()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 88, in _resolve
    obj = factory(self, scope, name)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 203, in _import
    module = __import__(module_python_path, scope, scope, [member], level=0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 59, in <module>
    fm = getFontManager()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 56, in getFontManager
    _system_font_manager = FontManager(mono_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 77, in __init__
    self.updateFontInfo(monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 244, in updateFontInfo
    self.addFontFiles(fonts_found, monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 151, in addFontFiles
    face = Face(fp)
NameError: global name 'Face' is not defined

Any idea what I’ve done wrong/how to fix it? I basically want the TextBox to look exactly the same as the TextStim that I originally used - I’m just seeing if it sorts out a memory leak issue that I have.


Memory Leak Issue - troubleshooting - 14 questions
#2

Do the Demos->stimuli->textbox demos work for you? I’ve reported elsewhere here that Textbox doesn’t work for me on current versions of Psychopy.


#3

I think this was fixed in a recent commit here on Github although I do not think it was pulled in to the most recent release.


#4

I think that’s right, fixed only a couple days ago, so no binary release yet.


#5

Just to answer your question, no the demo doesn’t work for me. I get this:

FreeType import Failed: dlsym(RTLD_DEFAULT, FT_Library_SetLcdFilterWeights): symbol not found
Traceback (most recent call last):
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/stimuli/textBoxStim/textbox_simple.py", line 28, in <module>
    units='norm',
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 119, in __call__
    obj = object.__getattribute__(self, '_resolve')()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 88, in _resolve
    obj = factory(self, scope, name)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 203, in _import
3.7357     WARNING     Monitor specification not found. Creating a temporary one...
    module = __import__(module_python_path, scope, scope, [member], level=0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 59, in <module>
    fm = getFontManager()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 56, in getFontManager
    _system_font_manager = FontManager(mono_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 77, in __init__
    self.updateFontInfo(monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 244, in updateFontInfo
    self.addFontFiles(fonts_found, monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 151, in addFontFiles
    face = Face(fp)
NameError: global name 'Face' is not defined

I guess I’ll try it with a previous release for now then

Thanks!


#6

I tried editing the relevant init.py file as per the Github file you’ve posted, and I’m still getting error messages:

FreeType import Failed: dlsym(RTLD_DEFAULT, FT_Library_SetLcdFilterWeights): symbol not found
3.7369     WARNING     Monitor specification not found. Creating a temporary one...
Traceback (most recent call last):
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/stimuli/textBoxStim/textbox_simple.py", line 28, in <module>
    units='norm',
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 119, in __call__
    obj = object.__getattribute__(self, '_resolve')()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 88, in _resolve
    obj = factory(self, scope, name)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 203, in _import
    module = __import__(module_python_path, scope, scope, [member], level=0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 59, in <module>
    fm = getFontManager()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 56, in getFontManager
    _system_font_manager = FontManager(mono_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 77, in __init__
    self.updateFontInfo(monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 244, in updateFontInfo
    self.addFontFiles(fonts_found, monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 151, in addFontFiles
    face = Face(fp)
NameError: global name 'Face' is not defined

#7

Updating to the most recent PsychoPy, I still get:

FreeType import Failed: dlsym(RTLD_DEFAULT, FT_Library_SetLcdFilterWeights): symbol not found
3.2181     WARNING     Monitor specification not found. Creating a temporary one...
Traceback (most recent call last):
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/demos/coder/stimuli/textBoxStim/textbox_simple.py", line 28, in <module>
    units='norm',
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 119, in __call__
    obj = object.__getattribute__(self, '_resolve')()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 88, in _resolve
    obj = factory(self, scope, name)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/contrib/lazy_import.py", line 203, in _import
    module = __import__(module_python_path, scope, scope, [member], level=0)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 59, in <module>
    fm = getFontManager()
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/__init__.py", line 56, in getFontManager
    _system_font_manager = FontManager(mono_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 77, in __init__
    self.updateFontInfo(monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 244, in updateFontInfo
    self.addFontFiles(fonts_found, monospace_only)
  File "/Applications/PsychoPy2.app/Contents/Resources/lib/python2.7/psychopy/visual/textbox/fontmanager.py", line 151, in addFontFiles
    face = Face(fp)
NameError: global name 'Face' is not defined

#8

As noted above by Alex and David, this fix has not yet been released.


#9

Thanks for that.

Ok - so I guess for the time being we’ll have to wait to use textBox-es?

I was only looking to use textBox-es because of this: https://stackoverflow.com/questions/36651509/psychopy-textstim-memory-leak-issue

Was the memory leaks issue with textStim ever resolved, or is still that a likely possible source of the memory leak that I currently have?