Repository: psychopy/psychopy

Issue:
visual.TextStim and autoDraw
Is there a reason why autoDraw is not possible with the initial call of visual.TextStim? It works with a subsequent setAutoDraw(True) call. Fix to text.py? This would be consistent with other visual.xxx functions.   


Discussion:
As far as I can tell, setting the `autoDraw` attribute on object instantiation is not possible with any (?) visual stimulus except for `Rect`, `Line`, `Circle`, and `PatchStim`. Thus I don't fully understand your question?

Still this appears to be a quite inconsistent behavior that should get improved by adding an `autoDraw` keyword argument to all the above-mentioned classes.

@ogigm Want to try a pull request on this one?
Yes, my question is just about the inconsistency between visual.TextStim and Rect, Line, Circle.
Rect, Line and Circle can take autoDraw=True on object instantiation whereas TextStim requires 
a .setAutoDraw(True) after instantiation. 
Polygon also allows autoDraw whereas DotStim does not.
@ogigm It's because `Rect` etc. accept "additional" keyword arguments via the `**kwargs` parameter and pass it to their parent class(es). An `autoDraw` parameter is thus implicitly passed to the parent.
OK, I see. My "fix" was to just hack text.py with an additional keyword argument and explicity set the autoDraw value. 
@ogigm I anticipate we'll provide a "proper" fix when working on #1523 :)

Resolving patch:
diff --git a/psychopy/visual/text.py b/psychopy/visual/text.py
--- a/psychopy/visual/text.py
+++ b/psychopy/visual/text.py
@@ -102,7 +102,8 @@ def __init__(self, win,
                  flipVert=False,
                  languageStyle='LTR',
                  name=None,
-                 autoLog=None):
+                 autoLog=None,
+                 autoDraw=False):
         """
         **Performance OBS:** in general, TextStim is slower than many other
         visual stimuli, i.e. it takes longer to change some attributes.
@@ -222,6 +223,8 @@ def __init__(self, win,
         self.setText(text, log=False)
         self._needUpdate = True
 
+        self.autoDraw = autoDraw
+
         # set autoLog now that params have been initialised
         wantLog = autoLog is None and self.win.autoLog
         self.__dict__['autoLog'] = autoLog or wantLog
diff --git a/psychopy/visual/textbox2/textbox2.py b/psychopy/visual/textbox2/textbox2.py
--- a/psychopy/visual/textbox2/textbox2.py
+++ b/psychopy/visual/textbox2/textbox2.py
@@ -80,6 +80,7 @@ def __init__(self, win, text,
                  lineBreaking='default',
                  name='',
                  autoLog=None,
+                 autoDraw=False,
                  onTextCallback=None):
         """
 
@@ -111,8 +112,8 @@ def __init__(self, win, text,
         flipHoriz
         flipVert
         editable
-        lineBreaking: Specifying 'default', text will be broken at a set of 
-            characters defined in the module. Specifying 'uax14', text will be 
+        lineBreaking: Specifying 'default', text will be broken at a set of
+            characters defined in the module. Specifying 'uax14', text will be
             broken in accordance with UAX#14 (Unicode Line Breaking Algorithm).
         name
         autoLog
@@ -224,7 +225,7 @@ def __init__(self, win, text,
         self.editable = editable
         self.caret = Caret(self, color=self.color, width=2)
 
-
+        self.autoDraw = autoDraw
         self.autoLog = autoLog
 
     def __copy__(self):


Test patch: