1. if you put a print statement in the OnOk and OnCancel methods you'll see that they are being called.
2. You are trying to use the dialog both modally and non-modally. Which do you want?
3a. If modal, then using the Close method is not the right thing to do. Use EndModal instead, passing the value that should be returned from the ShowModal call. (Normally it is the ID of the button whose event handler is calling EndModal.)
3b. If non-modal, then since it is a dialog you'll also want to have a handler for the EVT_CLOSE event that calls self.Destroy. By default dialogs are not destroyed when they are closed, so although calling self.Close does send the event, the dialog won't get destroyed automatically like frames do.
···
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
-----Original Message-----
From: Robin Dunn [mailto:robin@alldunn.com]
Sent: Monday, February 11, 2008 3:56 PM
To: wxPython-users@lists.wxwidgets.org
Subject: Re: [wxPython-users] Can somebody tell me whats wrong with this
code
Thippana, Prasoonadevi wrote:
I am not able to use events with these id wx.ID_OK and wx.ID_CANCEL.
import wx
class MessageDialog(wx.Dialog):
def __init__(self,parent,id,title):
wx.Dialog.__init__(self,parent,id,title)
1. if you put a print statement in the OnOk and OnCancel methods you'll
see that they are being called.
2. You are trying to use the dialog both modally and non-modally. Which
do you want?
3a. If modal, then using the Close method is not the right thing to do.
Use EndModal instead, passing the value that should be returned from
the ShowModal call. (Normally it is the ID of the button whose event
handler is calling EndModal.)
3b. If non-modal, then since it is a dialog you'll also want to have a
handler for the EVT_CLOSE event that calls self.Destroy. By default
dialogs are not destroyed when they are closed, so although calling
self.Close does send the event, the dialog won't get destroyed
automatically like frames do.
--
Robin Dunn
Software Craftsman http://wxPython.org Java give you jitters? Relax with wxPython!
---------------------------------------------------------------------
To unsubscribe, e-mail: wxPython-users-unsubscribe@lists.wxwidgets.org
For additional commands, e-mail: wxPython-users-help@lists.wxwidgets.org