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

frames_test.py (1.68 KB)

···

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