from Tkinter import *
import socket, sys
from PIL import Image, ImageTk
root = Tk()
root.title("Whois Tool")
root.resizable(0, 0)
text = Text()
text1 = Text()
image = Image.open("hacker2.png")
photo = ImageTk.PhotoImage(image)
label = Label(root, image=photo)
label.pack()
text1.config(width=15, height=1)
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)
b = Button(root, text="Enter", width=10, height=2, command=button1)
b.pack()
c = Button(root, text="Clear", width=10, height=2, command=clear)
c.pack()
scrollbar = Scrollbar(root)
scrollbar.pack(side=RIGHT, fill=Y)
text.config(width=60, height=15)
text.pack(side=LEFT, fill=Y)
scrollbar.config(command=text.yview)
text.config(yscrollcommand=scrollbar.set)
root.mainloop()
Run Code Online (Sandbox Code Playgroud)
如何调整根窗口的大小,或者如何调整图像大小以适应根窗口或按钮或标签等...谢谢
Sle*_*ock 29
对于500x500窗口,您可以使用
root.geometry("500x500")
Run Code Online (Sandbox Code Playgroud)
至于图像大小调整,我不相信Tkinter支持它.您必须使用诸如PIL之类的库来将图像大小调整为窗口分辨率.- 示例调整大小代码 -
| 归档时间: |
|
| 查看次数: |
47420 次 |
| 最近记录: |