Jesper Eskilson wrote:
> I'm having trouble in getting EVT_CLOSE() to function properly in a
> wxMiniFrame. For example
> EVT_CLOSE(self, self.OnClose)
> won't call the OnClose method when the user clicks on the Window's
> close-button. EVT_CLOSE() seems to work fine on normal frames.
> (Windows XP host)
Works for me on Win2k...
Then I'm sure you can tell me what's wrong with this test program:
···
--
from wxPython.wx import *
class MyApp(wxApp):
def OnInit(self):
frame = wxMiniFrame(NULL, -1, "Hello from wxPython", size = (400,300))
frame.Show(true)
self.SetTopWindow(frame)
EVT_CLOSE(self, self.on_close)
return true
def on_close(self, evt):
print "CLOSE!"
app = MyApp(0)
app.MainLoop()
--
I would expect "CLOSE!" to be printed before the application exits, but it isn't.
No, you weren't confused (before). It **wasn't** executed in your
code. The critical change is putting "frame" (not "self") as the
first argument in EVT_CLOSE. In other words the close event comes
from the frame not the application.
The second change (adding evt.Skip()) just lets the frame close
after printing the message.
···
--- Jesper Eskilson <jojo@virtutech.com> wrote:
Donnal Walter <donnalcwalter@yahoo.com> writes:
> You will need: EVT_CLOSE(frame, self.on_close) and then
> evt.Skip() in your on_close() method.
Ah. Thanks.
I was confused by the fact that the print-statement didn't show,
so I didn't think that the code was executed.
=====
Donnal Walter
Arkansas Children's Hospital
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
No, you weren't confused (before). It **wasn't** executed in your
code. The critical change is putting "frame" (not "self") as the
first argument in EVT_CLOSE. In other words the close event comes
from the frame not the application.
The real problem seems to have been that I register two handlers for the
close-event. The frame class inherits from another class which also calls
EVT_CLOSE(). Should that work, or can a window only have one target for the
close event?