Python TK 实现ping (二)
来源:互联网 发布:华科软件学院 编辑:程序博客网 时间:2024/05/21 09:01
简单实现3类网段的Ping,使用os的popen,返回结果为CMD实际输出
from tkinter import *
import os
# 控件布局
root = Tk()
top_frame = Frame(root)
botton_frame = Frame(root)
text_frame = Frame(root)
#L1 = Label(top_frame,text=' IP 地址 ')
#L1.pack(side='left')
#E1 = Entry(top_frame,textvariable=default_value,bd=2)
#E1.pack(side=LEFT)
def btn_click():
evalue = Ping()
def Ping():
#获取文本框里面的数值
startip = En1.get().split(".")
endip = En2.get().split(".")
ip3 = ".".join(startip[:3])
ip1 = int(startip[-1])
#print(ip1)
while 0<ip1<255:
result=os.popen("ping "+ip3+"."+str(ip1)).read()
text.insert(END,result)
text.update()
ip1 += 1
#print(ip1)
if ip1 > int(endip[-1]):
break
#B1 = Button(top_frame,text = '确定',command=btn_click)
#B1.pack(side=RIGHT)
botton_left = Frame(botton_frame)
botton_right = Frame(botton_frame)
label1 = Label(botton_left,text="%-5s" % "开始IP:")
label2 = Label(botton_left,text="%-5s" % "结束IP:")
label1.pack(side = 'top')
label2.pack(side = 'top')
En1 = Entry(botton_right)
En2 = Entry(botton_right)
En1.pack(side='top')
En2.pack(side='top')
B2 = Button(botton_frame,text='确定',command=btn_click)
B2.pack(side=RIGHT)
text = Text(text_frame,width = 30, height = 30)
text.pack()
#top_frame.pack()
botton_frame.pack()
botton_left.pack(side='left')
botton_right.pack(side='right')
text_frame.pack()
root.mainloop()
- Python TK 实现ping (二)
- Python下的TK(二)控件之Label
- Python ping 实现(一)
- 使用python Tk的实现tablepanel+treeview
- python实现ping源代码
- Tk:perl/Tk, TCL/Tk, python/Tk(Tkinter)示例
- Python下的TK(一)概述
- Tkinter之二(TCL/Tk在Python上的移植)
- python实现增强版ping
- python实现ping的源代码
- Python实现ping指定IP
- Python subprocess 实现ping (三)
- tcl/tk and python
- Python 中的 TK编程
- python GUI TK
- Tk on Python
- python Tk 组件
- tcl/tk实例详解——string(二)
- java-重载与重写
- windows10中创建Direct3D11设备出现0x887a002d错误,提示应用程序请求的操作依赖于已缺失或不匹配的 SDK 组件
- iOS判断身份证号码是否正确
- word交叉引用格式改为上标
- pktgen使用总结
- Python TK 实现ping (二)
- 541. Reverse String II
- BZOJ1965: [Ahoi2005]SHUFFLE 洗牌
- Excel常用电子表格公式大全1-2
- 1121. Damn Single 解析
- [TCP/IP]常见的HTTP状态码
- JavaScript打印金字塔
- 不容易系列1
- 在 Fragment 中使用 React Native