2014-03-31 11 views
0

我有一個wxPython腳本,它在單擊該按鈕後執行一個過程,並在wx.StaticText中顯示過程輸出。 問題是當我想重新執行這個過程時,所以我點擊按鈕並顯示舊的結果(第一個過程的輸出);這個古老的結果仍顯示在窗口上,而我也補充說,通常會隱藏它的指令:如何在單擊wxpython時擦除舊結果

這裏是我的代碼行:

def OnButton(self, e): 
    if self.res=="udpscan": 
     self.resultat1.SetLabel("") 
     ipad=self.ipadd.GetValue() 
     fromm=self.fr.GetValue() 
     too=self.to.GetValue() 
     ifc=self.intf.GetValue() 
     if len(ipad) <1 or len(too) < 1 or len(fromm) <1 or len(ifc) < 1: 
      wx.MessageBox('Please enter missing values','error',wx.OK) 
     else: 
      sp=subprocess.Popen(['python','udp_portscan.py',ifc,ipad,fromm,too],stdout=subprocess.PIPE) 
      text=sp.stdout.readlines() 
      text="".join(text) 
      self.resultat1.SetLabel(text) 

我嘗試添加其他說明資訊隱藏它但同樣的問題。 你能幫我嗎。謝謝

回答

0

sp似乎將sp.stdout中的所有前面的輸出存儲起來。

有可能是()的方式來清除它使用.kill:

 sp=subprocess.Popen(['python','udp_portscan.py',ifc,ipad,fromm,too],stdout=subprocess.PIPE) 
     text=sp.stdout.readlines() 
     sp.kill() 
+0

不幸的是,這並沒有解決我的問題 – farfalla

相關問題