[wxPython-users] How do I catch the close event on an XRC loaded dialog?
by Ron Arts other posts by this author
Dec 12 2004 5:29PM messages near this date
[wxPython-users] _get_document() in iewin
|
[wxPython-users] EVT_GRID_RANGE_SELECT GetTopRow
Hello,
I have a problem catching events in XRC loaded dialog.
I want to catch the close event. My code is as follows:
--------------
from wxPython.wx import *
from wxPython.xrc import *
class PreferencesDialog(wxDialogPtr):
def __init__(self,parent,res):
w = res.LoadDialog(parent, "Preferences")
wxDialogPtr.__init__(self, w.this)
self.Center()
EVT_CLOSE(self.OnClose)
def OnClose(self,e):
# do something here
in the main App:
def OnPrefs(self, event):
self.res = wxXmlResource("myapp_wdr.xrc")
dlg = PreferencesDialog(self, self.res)
dlg.ShowModal()
dlg.Destroy()
--------------
But I get the following error:
Traceback (most recent call last):
File "./astium.py", line 61, in OnPrefs
dlg = PreferencesDialog(self, self.res)
File "./prefs.py", line 34, in __init__
EVT_CLOSE(self.OnClose)
AttributeError: 'Dialog' object has no attribute 'OnClose'
If I leave out the EVT_CLOSE, the dialog works properly.
I use wxPythonGTK-py2.2-2.5.2.8-1, and wxDesigner to
generate the XML resources.
Ron
Attachments:
smime.p7s
Thread:
Ron Arts
wxgreg
|