Python Forum
[WxPython] Return code when closing the dialog
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[WxPython] Return code when closing the dialog
#1
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?
Reply
#2
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()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Is there is a printer dialog box in PySimpleGUI shaunfish 2 1,582 Aug-22-2022, 07:29 PM
Last Post: deanhystad
  How a QMainWindow can open a dialog? panoss 4 3,476 Feb-03-2022, 04:33 PM
Last Post: panoss
  [Tkinter] question for a tkinter dialog box RobertAlvarez424 2 2,205 Aug-25-2021, 03:08 PM
Last Post: RobertAlvarez424
  [Tkinter] cancelling open dialog gives empty string rwahdan 2 3,308 Jul-17-2021, 09:17 PM
Last Post: steve_shambles
  [PyQt] Received RunTimeError after script concludes, closing Dialog Window (clicking x-out) skipper0802 0 2,526 Oct-09-2020, 09:23 PM
Last Post: skipper0802
  PyQT5 : Unable to Create Another Dialog While One is Open iMuny 3 3,817 Jul-17-2019, 11:40 AM
Last Post: iMuny
  [WxPython] Any dialog that allow user to select file OR folder? buran 3 4,179 Apr-03-2019, 06:33 PM
Last Post: Yoriz
  [WxPython] how to run the dialog from another py file royer14 0 2,675 Jul-02-2018, 05:33 AM
Last Post: royer14
  FileBrowser dialog reverendfuzzy 5 4,598 May-06-2018, 01:56 PM
Last Post: reverendfuzzy
  I'm trying to create a simple yes/no dialog box RedSkeleton007 15 18,392 Apr-25-2018, 05:10 PM
Last Post: nilamo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020