Clicking the buttons work. But Closing the dialog with the X-Button in
the titlebar doesn't work. It always come into self._OnCancel. Why?
What happen there in the background?
Pressing the Cancel-Button and using the close-X-button in the titlebar
are definitly differnt things. Latter should create a OnClose or
something like that - not a OnCancel.
Clicking the buttons work. But Closing the dialog with the X-Button in
the titlebar doesn't work. It always come into self._OnCancel. Why?
What happen there in the background?
Pressing the Cancel-Button and using the close-X-button in the titlebar
are definitly differnt things. Latter should create a OnClose or
something like that - not a OnCancel.
The default EVT_CLOSE handler in dialogs sends a button event with an id of wx.ID_CANCEL. This is because 99% of the time you want the close to be the same as a cancel. When you don't then you can catch the EVT_CLOSE yourself, as you figured out.
There are also default handlers for the EVT_BUTTON events from the Cancel and Ok buttons. They will do some dialog things like calling the validators if there are any, and finally calling EndModal. This is something else that most of the time you want dialogs to do, at least for modal dialogs. Calling self.Close is the wrong thing for modal dialogs, and if you're not going to be using the dialogs modally then IMO you may as well just use a Frame with a Panel instead.