How to print text to the output window immediately

870 views
Skip to first unread message

S. Wolff

unread,
Apr 15, 2014, 10:28:32 AM4/15/14
to psychop...@googlegroups.com
I would like to run an experiment on screen 2 and view some logging information with subject responses on screen 1 simultaneously.
Using "print" commands I get all output at the end of the experiment.
Even with

from psychopy import logging
logging.console.setLevel(logging.WARNING)
[]
logging.log(level=logging.WARN, msg='test')
logging.flush()

no output appears until the end.
How can I print text to the output window immediately?
I am using PsychoPy 1.80.01 on a laptop with Windows 7.

Thanks in advance,
Stephan

S. Wolff

unread,
Apr 16, 2014, 7:12:18 AM4/16/14
to psychop...@googlegroups.com
Hi Samarth,

thanks, it works. I can use  the coder view as workaround.

Starting from builder the output window doesn´t show any log during a run even with "sys.stdout.flush()"

Stephan
 
Samarth Varma wrote:
Hi Stephan,

Not sure if it helps but - If I run the code from the coder view, I can see the output (of embedded print commands) as the code runs. 
I'm on 1.79.

Samarth

Jeremy Gray

unread,
Apr 15, 2014, 12:12:28 PM4/15/14
to psychop...@googlegroups.com
Hi Stephan,

The following will print text to the output window console immediately; it does not also log the message. Watch out for timing issues because printing can be slow if there's a lot of lines to print:

import sys
print "message"
sys.stdout.flush()  # ensure that the message appears now, regardless of print buffering




--Jeremy


--
You received this message because you are subscribed to the Google Groups "psychopy-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to psychopy-user...@googlegroups.com.
To post to this group, send email to psychop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/psychopy-users/d8c8930d-6d46-4021-b32e-099a2ac04673%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Samarth Varma

unread,
Apr 15, 2014, 12:23:07 PM4/15/14
to psychop...@googlegroups.com
Hi Stephan,

Not sure if it helps but - If I run the code from the coder view, I can see the output (of embedded print commands) as the code runs. 
I'm on 1.79.

Samarth

John Allen

unread,
Aug 5, 2021, 6:29:22 AM8/5/21
to psychopy-users
Replying to this old thread as it comes up above Discourse.psychopy.org in google - 

you don't actually need to flush the print buffer - all you need to do is move the mouse cursor over one of the other psychopy windows (either the builder/coder one or the Runner one) as this triggers PP to update the stdout view

cheers,
John
Reply all
Reply to author
Forward
0 new messages