【问题标题】:How to erase an old result when clicking on a wxpython单击wxpython时如何删除旧结果
【发布时间】:2014-03-31 10:20:03
【问题描述】:

我有一个 wxPython 脚本,它在单击按钮后执行一个进程,并在 wx.StaticText 中显示进程输出。 问题是当我想重新执行进程时,所以我点击按钮并显示旧结果(第一个进程的输出);这个旧结果仍然显示在窗口上,而我添加了一条通常会隐藏它的指令:

这是我的代码行:

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)

我试图添加其他指令来隐藏它,但同样的问题。 你能帮我吗。谢谢你

【问题讨论】:

    标签: python wxpython


    【解决方案1】:

    sp 似乎将所有以前的输出存储在 sp.stdout 中。

    可能有一种方法可以使用 .kill() 清除它:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-05-28
      • 2010-09-14
      • 1970-01-01
      • 1970-01-01
      • 2012-01-29
      • 2017-09-10
      • 1970-01-01
      相关资源
      最近更新 更多