Close All Windows

Is there a way to close all windows in the app instead of doing it manually like:

frame1.Destroy()

frame2.Destroy()

frame3.Destroy()

frame4.Destroy()

frame5.Destroy()

frame6.Destroy()

I have a program with lots of little forms that can be opened for settings and additional features. Just looking for a way to close everything when the main frame is closed. I have the function setup, just need a way to destroy all.

Well, sorta, but It all depends on how you have things setup and exactly what you are wanting behavior-wise.
Are the frames parented to a main frame or initial startup frame? When closing a main frame, all children are destroyed also.
So, when creating the extra frames, make the parent tof the frame, the main frame or something in that linage.

If so, then when creating your extra frames, you would just need to bind each frames wx.EVT_CLOSE event to the main frames close function if you want the ability to close everything from clicking the close button on any frame, if that is desired.
It doesn’t sound like it, but just mentioned it just in case.

Or maybe I am missing the Idea you are trying to implement…?
Normally all you would do is destroy the main window in most apps, and all the children follow suite.
basically like a domino stack trail.

mainDomino(parent=None)->d->d->d->d->d->d->d->d->d->etc…

···

On Friday, March 7, 2014 7:10:42 PM UTC-6, Josh wrote:

Is there a way to close all windows in the app instead of doing it manually like:

frame1.Destroy()

frame2.Destroy()

frame3.Destroy()

frame4.Destroy()

frame5.Destroy()

frame6.Destroy()

I have a program with lots of little forms that can be opened for settings and additional features. Just looking for a way to close everything when the main frame is closed. I have the function setup, just need a way to destroy all.

Or if all else fails you could use something along the following in
your wx.App.OnExit method.
# close any open top level windows
for w in wx.GetTopLevelWindows():
# need to use CallAfter, otherwise we might get two
DataDirty dlg’s
wx.CallAfter(w.Close)
Werner

···

Hi Josh,

  On 08/03/2014 06:21, Metallicow wrote:
    On Friday, March 7, 2014 7:10:42 PM UTC-6, Josh wrote:
        Is there a way to close all windows in the app

instead of doing it manually like:

frame1.Destroy()

frame2.Destroy()

frame3.Destroy()

frame4.Destroy()

frame5.Destroy()

frame6.Destroy()

          I have a program with lots of little forms that can be

opened for settings and additional features. Just looking
for a way to close everything when the main frame is
closed. I have the function setup, just need a way to
destroy all.

      Well, sorta, but It all depends on how you have things setup

and exactly what you are wanting behavior-wise.

      Are the frames parented to a main frame or initial startup

frame? When closing a main frame, all children are destroyed
also.

      So, when creating the extra frames, make the parent tof the

frame, the main frame or something in that linage.

      If so, then when creating your extra frames, you would just

need to bind each frames wx.EVT_CLOSE event to the main frames
close function if you want the ability to close everything
from clicking the close button on any frame, if that is
desired.

      It doesn't sound like it, but just mentioned it just in case.



      Or maybe I am missing the Idea you are trying to implement...?

      Normally all you would do is destroy the main window in most

apps, and all the children follow suite.

      basically like a domino stack trail.

mainDomino(parent=None)->d->d->d->d->d->d->d->d->d->etc…