how do i use "tkinter.createfilehandler" with a regular c program?

jepler at jepler at
Mon Nov 14 21:33:02 CET 2005

Compared to your program, I
 * Made sure that the slave program actually flushed its stdout buffers
 * didn't call read(), which will by default continue reading until
   it reaches EOF, not merely read the available data

#!/usr/bin/env python
import sys, time, Tkinter, itertools, _tkinter, os

if '-slave' in sys.argv:
    for i in itertools.count():
        print "This is a line of output:", i
    raise SystemExit

root = Tkinter.Tk()

fh = os.popen('%s -slave' % sys.argv[0])

def reader(*args):
    line = fh.readline()
    if not line:
        print "EOF from slave"
        raise SystemExit
    print "from slave: %r" % line

_tkinter.createfilehandler(fh, Tkinter.READABLE, reader)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list