[Tutor] how to display terminal messages indialog windowusingtkinter

Alan Gauld alan.gauld at btinternet.com
Sat Feb 23 02:55:39 CET 2008


"Kent Johnson" <kent37 at tds.net> wrote
>>> If you literally want print statements to appear in a dialog then 
>>> no,
>>> you can't do that (so far as I know!). But if you want the Tkinter
>>
>> Alan??? Redirect standard output. It doesn't have to be a file 
>> object. It
>> can be any object with a write method.
>
> Another way to do this, if you have control over the print 
> statements,
> is to use the logging package for output. It's not hard to make a 
> log
> handler that captures the messages and outputs them to a GUI panel.

Both of these suggestions are what I had in mind when I said
"create your own logging dialog with a text widget".

I don't know of any way to turn vanilla print statements into GUI 
visible
strings. Even redirecting stdout would require the creation of some 
kind
of custom widget that wrote to the GUI. (But I'd love to be wrong! :-)

Alan G. 




More information about the Tutor mailing list