how do i use "tkinter.createfilehandler" with a regular c program?
jepler at unpythonic.net
jepler at unpythonic.net
Mon Nov 14 15:33:02 EST 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():
time.sleep(1)
print "This is a line of output:", i
sys.stdout.flush()
raise SystemExit
root = Tkinter.Tk()
root.wm_withdraw()
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)
root.mainloop()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20051114/5ddead9e/attachment.sig>
More information about the Python-list
mailing list