Closing a wxPython Dialog
A quick note here to state that when closing a wx.Dialog and you want to make sure you get a valid result code back (where you haven’t setup the default OK and Cancel buttons) you can do so like this (assuming self is referring to the Dialog window):
self.EndModal(returnCode)
In this case, returnCode can be just about any integer, but it’s probably a good idea to do something like this:
self.EndModal(wx.ID_OK)
or
self.EndModal(wx.ID_CANCEL)
The other important note is that I noticed that when I left the self.Close() call in after the self.EndModal it still got called and it impacted the result code by incrementing it by 1 which of course broke the code. So thing to remember is to not call both. You should only call EndModal if it’s going to be a modal dialog window.
Technorati Tags: python, wxpython
No comments yet. Be the first.
Leave a reply