How to close a frame

Hi,

I know that I asked this question in december. I was on vacation.

The problem is my exampke have 2 windows. But my whole application is going to have 10 to 12 windows. So will this apporach workout for 10 to 12 windows?

Thanks

Prasoona

···

From: Alex Couper [mailto:amcouper@gmail.com]
Sent: Wednesday, December 19, 2007 4:25 AM
To:
wxPython-users@lists.wxwidgets.org
Subject: [wxPython-users] How to close a frame

I’ve looked at your code, and I think that you should have the main frame be the parent
of both of your panels.

So either, it creates them both, or when you are creating it in your OnOk method,
have it created like this:
self.Panel2(self.GetParent(),-1)

Personally I would create them in the main frame and have a switching method to change
between them that the sub panels can call.

def init(…)
self.panel1 = wx.Panel(…)
self.panel2 = wx.Panel(…)
self.panel1.Show()
self.panel2.Hide()

def switch(self):
self.panel1.Show(not self.panel1.IsShown())
self.panel2.Show(not self.panel2.IsShown ())

and then the sub panels just call self.GetParent().switch() to change views

There are other patterns for dealing with this swapping of views, and this is just one of them.

Alex Couper

---------- Forwarded message ----------
From: “Thippana, Prasoonadevi” pthippan@mc.com
To: wxPython-users@lists.wxwidgets.org
Date: Tue, 18 Dec 2007 15:13:53 -0500
Subject: RE: [wxPython-users] How to close a frame
I used frame1.Hide() and it is working. But I am intrested in the using panels.

So I tried creating the panels. But I am got confused on how to use panels seperately.

I have attached my code. I don’t know where I am doing the mistake.

Please help me.

Thanks


From: Alex Couper [mailto:amcouper@gmail.com]
Sent: Monday, December 17, 2007 2:30 PM
To: wxPython-users@lists.wxwidgets.org
Subject:
[wxPython-users] How to close a frame

If frame1 is registered to your main app, you won’t be able to do

frame1.Close()
frame2.Show()

as the Close() method will end the app.

You could use frame1.Hide().

Looking at your test code, it may be more appropriate for you to use wx.FramePanel.
If you think of your Frame1 as your window holder, and then make all of the different screens out of framepanel, you won’t need to be creating and closing different frames, but rather use Show() and Hide() on the child panels instead.

Thats my thoughts anyway.

Alex Couper

---------- Forwarded message ----------
From: “Thippana, Prasoonadevi” pthippan@mc.com
To: <
wxPython-users@lists.wxwidgets.org>
Date: Mon, 17 Dec 2007 14:14:09 -0500
Subject: How to close a frame
Hi,

How can I close a one frame and instantiate another frame in same function? For example In function OnOk, I am calling Frame2 class.but I want to close Frame1.

class Frame1(wx.Frame):
def init(self, parent, id, title = “Frame3”):
wx.Frame.init(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
self.SetIcon(wx.Icon(‘PyCrust.ico’,wx.BITMAP_TYPE_ICO))
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)

        Ok = wx.Button(self.mainpa, -1, 'Ok',wx.Point(50,50))
        self.Bind(wx.EVT_BUTTON,self.OnOk,Ok)

def OnOk(self,event):
            self.dlg1 = Frame2(self, -1)
            self.dlg1.Show(True)

class Frame2(wx.Frame):
def init(self, parent, id, title = “Frame2”):
wx.Frame.init(self, parent,-1,title,wx.DefaultPosition,wx.Size(300,150))
self.SetIcon(wx.Icon(‘PyCrust.ico’,wx.BITMAP_TYPE_ICO))
self.mainpa = wx.Panel(self,-1,wx.DefaultPosition, wx.DefaultSize)

Thanks

Prasoona