Reputation: 19
When I click on the run button directly without clicking on CV button or IR button that I've created, I will close my window. But if I click on CV button or IR button then I clicked on Exit button, I will not work. I try to remove app.MainLoop() inside both CV and IR button but still not working.
p/s CV_Button and IR_Button will call another .py file which is a GUI. I dont know how to call main in python but at least it works and I dont even know if is right or wrong.
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()
Upvotes: 0
Views: 1120
Reputation: 33111
You can not have more than one wx.App per application. Thus, you cannot have two mainloops either. There needs to be one instance of wx.App (or wx.PySimpleApp, although that's deprecated). Remove the others and it will probably work.
Upvotes: 1