Python Forum
[WxPython] Return code when closing the dialog - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: GUI (https://python-forum.io/forum-10.html)
+--- Thread: [WxPython] Return code when closing the dialog (/thread-20476.html)



Return code when closing the dialog - ioprst - Aug-13-2019

There is own dialogue which is inherited from wx.Dialog.

There is one button:

button_ok = wx.Button (self, wx.ID_OK, "OK")
Buttons with identifier wx.ID_CANCEL no.

Why, when I close the dialog through "X", then the return code is wx.ID_OK? Shouldn't I get wx.ID_CANCEL?


RE: Return code when closing the dialog - jefsummers - Aug-13-2019

Respond to the EVT_CLOSE event and SetReturnCode(wx.ID_CANCEL) in that event handler. Also, return codes are usually associated with a modal dialog so for best behavior call the dialog with ShowModal()