【发布时间】:2014-11-03 21:32:57
【问题描述】:
我想使用 python wxpython 按钮单击事件启动一个 Windows 批处理文件。
import wx
import subprocess
class MyFrame(wx.Frame):
""" Dervice new class of Frame"""
def __init__ (self, parent, title)
wx.Frame.__init__(self,parent,title=title,size=(410,355))
panel = wx.Panel(self)
startbutton = wx.Button(panel, label="Start", pos=(200,70), size=(80,25))
self.Bind(wx.EVT_BUTTON,self.StartClicked, startbutton)
def StartClicked(self, event):
print "Session started"
self.filepath="C:\\cygwin64\\Sipp_3.2\\Auto.bat"
subprocess.call(self.filepath)
print "Session ended"
if __name__ == '__main__':
app = wx.App()
frame = MyFrame(None, "CallGenerator")
frame.Show()
app.MainLoop()
当我单击“开始”按钮时,每次都会输出以下内容。
>Session started
>Session ended
>Session started
>Session ended
代码不会打开批处理文件。但是当我通过命令提示符执行时,批处理文件是通过命令提示符执行的。
我正在使用 pyscripter,如何将批处理文件作为新窗口打开?
同样,如果批处理文件包含连续 ping (ping ipaddress -t),则 GUI 会崩溃。
现在我的两个问题的解决方案是什么。
【问题讨论】: