[PyQt] Using Python's "print" or sys.stdout.write( "str" ) inside of PyQt4.

Hans-Peter Jansen hpj at urpla.net
Thu Oct 2 20:26:13 BST 2008


Am Mittwoch 01 Oktober 2008 schrieb Peter Lindener:
> Dear
>     Hans -
>
>        I gather that PyQt's problem with using "print" or
> "sys.stdout.write()" inside of PyOpenGL's "GL.Widget.paint()" call back
> function has something to do with Qt's redirection of the C level
> "stdout" output stream?.

I don't think that Qt by itself fiddles in this area, but looking into the 
source is always superior to hand waving ;-)

> I'm not sure exactly how PyQt handles any I/O 
> stream redirection logic that may need to be looked after inside of Qt,
> especially where it sometime comes into interplay with call back like
> functions such as in the PyQt.OpenGL example code sent in my last
> message.   Any suggestions as to where I might best start looking for
> what is going on with Python's failure to print inside of IDE's but not
> outside where it works just fine, and/or how to fix this impediment to
> interactive Python debugging?

I would stop using standard streams. Use the toolkit. That's what it been 
made for. Alternatively/additionally, the logging package is very useful in 
this area, too. Just log to a file, and watch it from another console (less 
+F file.log is your friend).

Have fun,
Pete


More information about the PyQt mailing list