当我直接点击运行按钮而不点击我创建的CV按钮或IR按钮时,我将关闭窗口。但是,如果我点击CV按钮或IR按钮,然后我点击退出按钮,我将无法工作。我尝试在CV和IR按钮内删除app.MainLoop()但仍无法正常工作。
p / s CV_Button和IR_Button将调用另一个.py文件,这是一个GUI。我不知道如何在python中调用main但至少它有效,我甚至不知道是对还是错。
def CV_Button(self, event): # wxGlade: Main.<event_handler>
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
MainFrame = CV(None, -1, "")
app.SetTopWindow(MainFrame)
MainFrame.Show()
app.MainLoop()
event.Skip()
def IR_Button(self, event): # wxGlade: Main.<event_handler>
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
MainFrame = IR(None, -1, "")
app.SetTopWindow(MainFrame)
MainFrame.Show()
app.MainLoop()
event.Skip()
def Exit_Button(self, event): # wxGlade: Main.<event_handler>
self.Close(True)
event.Skip()
if __name__ == "__main__":
app = wx.PySimpleApp(0)
wx.InitAllImageHandlers()
Main = Main(None, -1, "")
app.SetTopWindow(Main)
Main.Show()
app.MainLoop()
答案 0 :(得分:1)
每个应用程序不能有多个wx.App。因此,您也不能有两个主循环。需要有一个wx.App实例(或wx.PySimpleApp,尽管已弃用)。删除其他人,它可能会工作。