wxpython 按钮 禁用_wxPython:停止使用wxButton线程

如何通过单击wx按钮停止线程?在

这是我的代码:def startMonitor(self,event):

selectedInterface = self.interfaces_cblist.GetValue()

Publisher().sendMessage(("test"),selectedInterface)

self.Close()

selectInterfaceStr = str(selectedInterface)

if len(selectedInterface) == 0:

noSelect_error = wx.MessageDialog(None,"Please select an interface","",wx.OK|wx.ICON_ERROR)

noSelect_error.ShowModal()

else:

monitorStarted = wx.MessageDialog(None,"Monitor on %s started"%selectInterfaceStr,"",wx.OK|wx.ICON_ERROR)

monitorStarted.ShowModal()

self.monitorInterface_button.Disable()

threading.Thread(target=self.camtableDetection,args=(selectInterfaceStr,)).start()

threading.Thread(target=self.dhcpexhaustion,args=(selectInterfaceStr,)).start()

def camtableDetection(self,getInterface):

global interface

interface = str(getInterface)

THRESH=(254/4)

START = 5

def monitorPackets(p):

if p.haslayer(IP):

hwSrc = p.getlayer(Ether).src

if hwSrc not in hwList:

hwList.append(hwSrc)

delta = datetime.datetime.now() - start

if((delta.seconds > START) and ((len(hwList)/delta.seconds) > THRESH)):

print "[*]- Detected CAM Table Attack."

#camAttackDetected = wx.MessageDialog(None,"Cam Attack Detected","",wx.ICON_ERROR)

#camAttackDetected.ShowModal()

hwList = []

start = datetime.datetime.now()

sniff(iface=interface,prn=monitorPackets)

def dhcpexhaustion(self,getInterface):

interface = str(getInterface)

global reqCnt

global ofrCnt

reqCnt = 0

ofrCnt = 0

def monitorPackets(p):

if p.haslayer(BOOTP):

global reqCnt

global ofrCnt

opCode = p.getlayer(BOOTP).op

if opCode == 1:

reqCnt=reqCnt+1

elif opCode == 2:

ofrCnt=ofrCnt+1

print "[*] - "+str(reqCnt)+" Requests, "+str(ofrCnt)+" Offers."

sniff(iface=interface,prn=monitorPackets)

当我点击一个按钮时,我想停止线程,但不知道怎么做。在

有自行中止技术,但我不知道如何在代码中应用它。在

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值