Display console output to status bar in Tkinter?
richard_chamberlain at my-deja.com
richard_chamberlain at my-deja.com
Thu Aug 10 05:22:13 EDT 2000
Hi,
One way you could do it is by redirecting the file to your own object
that implements write, writelines etc.
sys.stdout attaches itself to a file like object and calls write
against it - you could capture these writes and then direct them to
where you want them.
idle does a similar thing - have a look in PyShell.py especially at
PseudoFile class which is shown below:
class PseudoFile:
def __init__(self, shell, tags):
self.shell = shell
self.tags = tags
def write(self, s):
self.shell.write(s, self.tags)
def writelines(self, l):
map(self.write, l)
def flush(self):
pass
You just then need to redirect the output somewhere useful.
Richard
In article <#Toh7OpAAHA.401 at cpmsnbbsa08>,
"rhyde99" <rhyde99 at email.msn.com> wrote:
> I need to know how it is possible to display only the last line of
> stdout/stderr output to my Tkinter status bar. In the Python FAQ I
saw a
> way to catch stdout/stderr output, but this method concatenates all
of the
> output. I just need the last line.
>
> I hope this is clear, and that someone can help!
>
> Thanks in advance
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
More information about the Python-list
mailing list