Python streaming data with GUI running
Posted: Thu May 25, 2006 10:23 am
OK! So I have a program that will connect to a server through telnet and open a little GUI thing to input text. I want all the incoming stuff from the server to be printed to the terminal window while everything from the little GUI box goes to the server.
The box to server works just fine, the problem is that I don't know how to have a loop that gets the data from the server while running the GUI box. If anyone can help out that would be fantastic. here is the code I am struggling with:
[/syntax]
The box to server works just fine, the problem is that I don't know how to have a loop that gets the data from the server while running the GUI box. If anyone can help out that would be fantastic. here is the code I am struggling with:
Code: Select all
#! /usr/bin/env python
from Tkinter import *
import telnetlib
HOST = 'localhost'
PORT = 4000
telnet = telnetlib.Telnet(HOST, PORT)
def Display():
global enText
global telnet
telnet.write(enText.get())
print str(telnet.read_some())
return True
root = Tk()
lbText = Label(root, text="Enter Text:")
lbText.grid(row=0, column=0)
enText = Entry(root)
enText.grid(row=0, column=1, columnspan=3)
btnDisplay = Button(root, text="Send", command=Display)
btnDisplay.grid(row=0, column=4)
root.mainloop()