Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

[open] draw_text

edited March 2015 in PyGaze

Sorry, I placed the question in the wrong forum (OpenSesam).
The question is how one can manage word wrap in libscreen.draw_text. In psychopy / visual it's possible to use wrapWidth=xxx,
but there is no way to arrange for this in lib_screen.
Thanks for answering this question.


  • edited 9:29AM


    There's no direct way to do this, but you could hack into PyGaze to set the wrap width with PsychoPy directly. The thing to know is that when you call Screen.draw_text, PyGaze creates a psychopy.visual.TextStim and appends it to Screen.screen, which is a list. So I think you could do something like this. Of course, this assumes that you're using the psychopy disttype in PyGaze.

    Warning: This is blindly coded and untested, just to show the general idea!

    # Assume that my_screen is a PyGaze `Screen` object
    textstim = my_screen.screen[-1]
    textstim.wrapWidth = 400


  • edited 9:29AM


    As @sebastiaan mentioned, if you are using the PsychoPy DISPTYPE, you can manipulate the psychopy.visual instances in the my_screen.screen list.

    For both PsychoPy and PyGame, you can include "\n" in your text. This will insert a newline wherever you put it. For example, "You won!\nThanks for participanting!\n\n(press space to exit)" will look like the following:

    You won!
    Thanks for participanting!
    (press space to exit)

    Good luck!


Sign In or Register to comment.