我想使用python wxpython按钮单击事件启动一个windows批处理文件。使用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将崩溃。
现在我的两个问题的解决方案是什么。
大麦克,谢谢。它现在的工作:) – vallikkv 2014-11-04 17:49:49