我正在开发一个登录motorolla调制解调器的工具,我让它工作并在python控制台上显示输出,这个工具有两个部分,一个部分是gui和按钮、标签和文本框。我想让输出显示在 Gui 而不是控制台上。我怎样才能做到这一点
这是文件:
从 Tkinter 进口 * 进口摩托罗拉
类应用程序(对象):定义初始化(自我):
self.fen = Tk()
self.fen.title("Motorola tool V 0.1")
self.fen.geometry("720x480")
Label(self.fen,
text = "IP address").grid(row=0)
#self.entree = MaxLengthEntry(self.fen, maxlength=5)
self.entree1 = Entry(self.fen)
self.entree1.grid(row=0, column=1)
Label(self.fen,
text = "Password").grid(row=2)
#self.entree = MaxLengthEntry(self.fen, maxlength=5)
self.entree2 = Entry(self.fen)
self.entree2.grid(row=2, column=1)
Button(self.fen, text = 'Connect',
command = self.launch).grid(row = 3, column=2)
Button(self.fen, text = 'Disconect',
command = self.exits).grid(row = 3, column=3)
Button(self.fen, text = 'Quit',
command = self.fen.quit).grid(row = 5, sticky = E)
self.output = Text(self.fen)
self.output.grid(row = 7, column = 1)
self.fen.mainloop()
def launch(self):
self.ip = self.entree1.get()
self.passw = self.entree2.get()
print self.ip, self.passw
if self.passw == "":
self.entree2.config(bg = 'red')
self.fen.after(1000, self.empty)
else:
self.f = motorola.Motorola(self.ip, self.passw)
self.f.sh_dsl()
def empty(self):
self.entree2.configure(bg='white')
def exits(self):
try:
self.f.disconnect()
except AttributeError:
print "You are not connected"
a = 应用程序()
摩托罗拉文件:
类摩托罗拉(对象):定义初始化(自我,IP,密码):
self.ip = ip
self.passw = passw
print "connect on the modem"
self.tn = telnetlib.Telnet(self.ip, '2323' , timeout =5)
self. tn.read_until("login: ")
self.tn.write('radadmin\r\n')
self.tn.read_until("Password:")
self.tn.write(self.passw+"\r\n")
data = self.tn.read_until(">")
print "you are connected"
print data,
def断开(自我):
self.tn.close()
print "disconnect from the modem"
导入 telnetlib
一旦我用启动摩托罗拉模块的按钮连接调制解调器,数据如何显示在gui模块的框架文本上?
谢谢