Hello, I have the following code, and I was wondering if anyone had this behavior occur.
WIth a wxDialog, if I hit the window manager’s close button on the dialog, it is properly disposed of, and mainloop is exited. However, if I hit the escape key, the dialog disappears, but the mainloop still remains. Can anyone tell me what is wrong?
Thanks!
from wxPython.wx import *
``
class MyApp(wxApp):
def OnInit(self):
maindlg = mywxDialog(NULL, -1, "Hello from wxPython", (-1,-1), (60,120))
maindlg.Show(true)
self.SetTopWindow(maindlg)
mainsizer = wxBoxSizer(wxHORIZONTAL)
b1 = wxButton(maindlg, -1, "OK", (15,30), (-1,-1), 0)
mainsizer.Add(b1, 1, wxALL, 3)
maindlg.SetAutoLayout(true)
maindlg.SetSizer(mainsizer)
mainsizer.Fit
mainsizer.SetSizeHints(maindlg)
EVT_END_SESSION(self,self.OnCloseWindow)
return true
def OnCloseWindow(self, event):
print "foo, test"
b1.Destroy()
mainsizer.Destroy()
maindlg.Destroy()
class mywxDialog(wxDialog):
def __init__(self, parent, id, title, *rest):
wxDialog.__init__(self, parent, id, title, *rest)
EVT_CLOSE(self, self.OnCloseWindow)
EVT_CHAR(self, self.OnChar)
def OnCloseWindow(self, event):
print "OnCloseWindow"
self.Destroy()
def OnChar(self, event):
print "OnChar"
print event.GetKeyCode()
``
class myLog(wxLog):
def OnLog(level, message):
print level + ":" + message
``
app = MyApp(0)
app.MainLoop()
``