TextBox invalid width

Hello,

I am using Psychopy 3.0.4 & Python 3.7, and I have issues using visual.TextBox.
I first did all my script with visual.textStim and it worked well, but visual.TextBox returns me an error :

File “/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/textwrap.py”, line 248, in _wrap_chunks
raise ValueError(“invalid width %r (must be > 0)” % self.width)
ValueError: invalid width 0 (must be > 0)
Exception ignored in: <function TextGrid.del at 0x1285e1c80>
Traceback (most recent call last):
File “/Users/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/textgrid.py”, line 279, in del
self._text_document._free()
AttributeError: ‘NoneType’ object has no attribute ‘_free’

Hello,
I use the coder interface of psychopy, and I have basic issues with the visual.TextBox

Psychopy 3.0.4 & Python 3.7

With this simple code :

from psychopy import visual
from psychopy import core

# create window
win = visual.Window()

# Create textstim
text = visual.TextBox(win,
                        text="This is your text")

text.draw()
win.flip()
core.wait(2000)

I have this error :

Traceback (most recent call last):
  File "untitled.py", line 9, in <module>
    text="This is your text")
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/contrib/lazy_import.py", line 120, in __call__
    return obj(*args, **kwargs)
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/__init__.py", line 397, in __init__
    self._text_grid._createParsedTextDocument(self._text)
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/textgrid.py", line 187, in _createParsedTextDocument
    self._text_document = parsedtext.ParsedTextDocument(f, self)
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/parsedtext.py", line 49, in __init__
    self._parse(0, len(self._text))
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/parsedtext.py", line 137, in _parse
    update_lines)
  File "/Users/paulb/Envs/myenv/lib/python3.7/site-packages/psychopy/visual/textbox/parsedtext.py", line 146, in _wrapText
    for linestr in self._text_wrapper.wrap(para_text):
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/textwrap.py", line 354, in wrap
    return self._wrap_chunks(chunks)
  File "/usr/local/Cellar/python/3.7.2_2/Frameworks/Python.framework/Versions/3.7/lib/python3.7/textwrap.py", line 248, in _wrap_chunks
    raise ValueError("invalid width %r (must be > 0)" % self.width)
ValueError: invalid width 0 (must be > 0)

I think the error is because your textbox size is not specified. Try:

from psychopy import visual
from psychopy import core

# create window
win = visual.Window()

# Create textstim
text = visual.TextBox(win,
                        text="This is your text",
                        font_size=21,
                        font_color=[-1,-1,1], 
                        size=(1,.3),
                        pos=(0.0,0.25), 
                        grid_horz_justification='center',
                        units='norm',)

text.draw()
win.flip()
core.wait(2000)

Thank you, it solved it.
As I never used TextBox yet, I did not know size was a requirement, and this page is not arguing on this point.

Cheers