pyinstaller program keeps running in background after closing

时间:2017-08-04 13:04:50

标签: python wxpython pyinstaller

I have a pyinstaller executable wxpython GUI that works fine. The only issue I am having is that when I close the program with the X button on the window, it stays running in the background. Does anyone know of a way to kill the process when the window X button is clicked?

1 个答案:

答案 0 :(得分:1)

您可以绑定Close窗口事件,wx.EVT_CLOSE与其他事件一样,即:

self.Bind(wx.EVT_CLOSE, self.OnExit)

然后在你OnExit(self,event)中使用self.Destroy()
如果这仍然不起作用,你几乎肯定还有一些东西仍然存在。如果您无法跟踪该问题,则解决方法是使用sys.exit(),但确实应该不赞成。