[wxPython-users] Re: How to do cleanup when system shutdown
closes the app?
roee88 shlomo
roee88 at gmail.com
Tue Jul 4 00:20:18 PDT 2006
I think you should also use
frame.Bind(wx.EVT_CLOSE, self.Query)
I always use all hust in case: EVT_CLOSE, EVT_QUERY_END_SESSION,
EVT_END_SESSION.
As a note: you can't set wx.App as a wx.MessageDialog parent.
you should change it to dlg =3D wx.MessageDialog(self.frame, 'OK to Quit?',
...
(of course self.frame =3D frame).
On 7/4/06, Avery.Andrews at anu.edu.au <Avery.Andrews at anu.edu.au> wrote:
>
>
> This thread has been in abeyance for a bit, so I'll review and rephrase.
> I have an app which I want to save its data when the system shuts down,
> as well as when the app itself is explicitly shut down. It seems like
> processing the EVT_QUERY_END_SESSION ought to be the right thing to do,
> but, on the Windows platform, using Python 2.4.2 and Ansi wxpython 2.6.3.2
> (and various prior versions), this code doesn't produce any dialog window
> on system shutdown:
>
> class RunnerApp(wx.App):
> def OnInit(self):
> frame =3D RunnerFrame(None, "TreeRunner")
> self.SetTopWindow(frame)
> frame.Show(True)
> self.Bind(wx.EVT_QUERY_END_SESSION, self.Query)
> return True
>
> def Query(self, event):
> dlg =3D wx.MessageDialog(self, 'OK to Quit?',
> 'A Message Box',
> wx.YES_NO
> )
> answer =3D dlg.ShowModal()
> dlg.Destroy()
> if answer!=3Dwx.ID_YES:
> return 1
> return 0
>
> if __name__ =3D=3D '__main__':
>
> app =3D RunnerApp(redirect=3D0)
> app.MainLoop()
>
> So is it possible that the EVT_QUERY_END_SESSION msg is simply not being
> processed in the Windows version of wxpython? Or an I making some mistake
> in using it.
>
> - Avery Andrews
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wxPython-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wxPython-users-help at lists.wxwidgets.org
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wxpython-users/attachments/200607=
04/54f6e63d/attachment.htm
More information about the wxpython-users
mailing list