0
def WhoisWin():
win1 = Toplevel()
win1.title("Whois")
win1.config(bg="black")
win1.geometry("300x300")
win1.resizable(0,0)
text = Text()
text1 = Text()
text1.config(width=15, height=1)
text1.config(bg="black", fg="white")
text1.pack()
def button1():
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("com.whois-servers.net", 43))
s.send(text1.get("1.0", END) + "\r\n")
response = ''
while True:
a = s.recv(4096)
response += a
if a == '':
break
s.close()
text.insert(END, response)
def clear():
text.delete("1.0", END)
text1.delete("1.0", END)
frame = Frame(win1)
frame.config(bg="black")
frame.pack(pady=10, padx=5)
b = Button(frame, text="Enter", width=10, height=2, command=button1)
b.config(fg="white", bg="black")
b.pack(side=LEFT, padx=5)
c = Button(frame, text="Clear", width=10, height=2, command=clear)
c.config(fg="white", bg="black")
c.pack(side=RIGHT, padx=5)
scrollbar = Scrollbar(win1)
scrollbar.pack(side=RIGHT, fill=Y)
text.config(width=35, height=15, bg="black", fg="white")
text.pack(side=LEFT, fill=Y)
scrollbar.config(command=text.yview)
text.config(yscrollcommand=scrollbar.set)
這僅僅是一個子窗口,當您單擊菜單上彈出,我沒有得到任何錯誤,但文字和Tex1是不是子窗口上可見,但是當我運行這個代碼在它自己的根窗口它工作只是發現,也許身份是亂了或什麼的?任何幫助將不勝感激,謝謝。Tkinter的Toplevel小窗口部件
謝謝你幫助很多,它現在的作品:) – SourD 2010-11-07 02:05:38
是迂腐,第一個參數不告訴Tkinter「什麼打包文本小工具」。相反,它定義了小部件的父代。副作用是'grid','pack'和'place'默認將小部件放在他們的父母身上。 – 2010-11-07 23:10:07