Reputation:
When you click on Cancel, it cancels... When you click OK, it pops the dialog back on. How can I fix this?
def quitApp(self, event):
dial = wx.MessageDialog(None, 'Are you sure you want to quit?','Quit', wxYES | wxNO)
if dial.ShowModal() == wxID_YES:
self.Close(true)
Upvotes: 0
Views: 2853
Reputation: 1
def CloseTheProgram( self, event ):
dial = wx.MessageDialog(None, 'Are you sure you want to quit?','Quit', wx.YES | wx.NO)
if dial.ShowModal() == wx.ID_YES:
self.Close(True)
Upvotes: 0
Reputation: 25759
Could it be that quitApp is called by the system CloseEvent handler? In that case, self.Close(true) only triggers a new CloseEvent, which in that case will call quitApp again and show a new dialog... and so on.
I suggest you quit the application with sys.exit(0) instead of self.Close(true).
Upvotes: 5
Reputation: 20744
You'll need to provide more code. It looks like something else is triggering the quitApp
function. Your function right there doesn't loop. It might be looping because it's trying to close and the event keeps getting called. Try using self.Destroy()
instead to close the frame.
Upvotes: 1
Reputation: 48028
Without knowing more (see my comment), I can take a few stabs:
self
is an App, then self.ExitMainLoop()
will close the program.self
is a Frame, then self.Close(True)
is appropriate.self
is anything else, then sys.exit(0)
will shut down the Python Interpreter and close the program.Upvotes: 2