James Henstridge writes:
> If so, then you want to use the input_add() function, which adds a
> callback that will be called when there is info to be read/written
> on the fd (depends on the flags passed to input_add). I don't have any
> example code for this at the moment though.
Something like the following will work, although I have no idea how to
detect EOF, since I'm using this code to read a continual data stream
from a GPS receiver.
#!/usr/bin/python
import GDK
from gtk import *
def handle_line(line):
print "finger: ",line
def handle_input(sock, condition):
line = s.recv(1024)
if not line: return # arguably we should do more.
lines = lines + line
lines = string.split(lines, '\n')
for line in lines[:-1]:
handle_line(line)
lines = lines[-1]
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("127.0.0.1", 79))
input_add(s, GDK.INPUT_READ, handle_input)
mainloop ()
--
-russ nelson <[EMAIL PROTECTED]> http://russnelson.com
Crynwr sells support for free software | PGPok | Watch out! He's got an
521 Pleasant Valley Rd. | +1 315 268 1925 voice | opinion, and he's not
Potsdam, NY 13676-3213 | +1 315 268 9201 FAX | afraid to share it!
_______________________________________________
pygtk mailing list [EMAIL PROTECTED]
http://www.daa.com.au/mailman/listinfo/pygtk