Swapping panels in a superframe

Thank you all for your help. :slight_smile:

Here is the code that does what I required (not polished off), incase anyone has a similar problem. I used the auimanager method as it seemed to be the cleanest approach.

#!/usr/bin/python

spreadsheet.py

import wx
import wx.aui

···

#---------------------------------------------------------------------------

class SuperClass(wx.Frame):
def init(self):
wx.Frame.init(self,None,-1,“Test Frame”, size=(800, 600))
global manager, SuperParent
SuperParent = self
manager = wx.aui.AuiManager(self)
manager.AddPane(StartScreen(self), wx.aui.AuiPaneInfo().Name(‘Start’).Show())
manager.AddPane(EditScreen(self),
wx.aui.AuiPaneInfo().Name(‘Edit’).Hide())
manager.AddPane(InputScreen(self), wx.aui.AuiPaneInfo().Name(‘Input’).Hide())
manager.AddPane(SearchScreen(self), wx.aui.AuiPaneInfo().Name(‘Search’).Hide())
manager.Update()

def OnQuit(self, event):
    self.Close(True)

class StartScreen(wx.Panel):
def init(self, parent, id=-1):
wx.Panel.init(self, parent, id, size=(600, 800))

    vbox = wx.BoxSizer(wx.VERTICAL)
   
    global rb
     rb =

wx.RadioBox(self, -1, label=“Make your selection”, choices=[‘Input’
,‘Edit’,‘Search’],style=wx.VERTICAL)

    sizer = wx.BoxSizer(wx.HORIZONTAL)
   
    okButton = wx.Button(self, -1, 'Ok', size=(50, 20))
    wx.EVT_BUTTON(self, okButton.GetId(), self.OnSelection)

    closeButton = wx.Button(self, -1, 'Close', size=(50, 20))
    wx.EVT_BUTTON(self, closeButton.GetId(), parent.OnQuit)
   
    sizer.Add(okButton, 1)
    sizer.Add(closeButton, 1, wx.LEFT, 5)
     vbox.Add(sizer, 1, wx.ALIGN_CENTER | wx.TOP |

wx.BOTTOM, 110)

    self.SetAutoLayout(True)
    self.SetSizer(vbox)
   
   
def OnSelection(self, event):
    manager.GetPane("Start").Hide()
    if rb.GetString(rb.GetSelection()) == 'Input':
        manager.GetPane("Input").Show()
    elif rb.GetString(rb.GetSelection()) == 'Edit':
        manager.GetPane("Edit").Show()
    else:
        manager.GetPane("Search").Show()

manager.Update()

class InputScreen(wx.Panel):
def init(self, parent, id=-1):
wx.Panel.init(self, parent, id, size=(600, 800))
hbox = wx.BoxSizer(wx.HORIZONTAL)

    #---- Selection Button
    OkButton = wx.Button(self, -1, 'Ok', size=(50, 20))
    wx.EVT_BUTTON(self, OkButton.GetId(), parent.OnQuit)
    hbox.Add(OkButton, 1)
    #----------------------------------------------------
   
    #---- Back Button
     BackButton = wx.Button(self, -1, '<- Back',

size=(50, 20))
wx.EVT_BUTTON(self, BackButton.GetId(), self.OnBack)
hbox.Add(BackButton, 1, wx.LEFT, 5)
#----------------------------------------------------

    #---- close Button
    closeButton = wx.Button(self, -1, 'Close', size=(50, 20))
    wx.EVT_BUTTON(self, closeButton.GetId(), parent.OnQuit)
    hbox.Add(closeButton, 1, wx.LEFT, 5)
    #----------------------------------------------------
    self.SetSizer(hbox)

def OnBack(self, event):

manager.GetPane(“Input”).Hide()
manager.GetPane(“Start”).Show()
manager.Update()

class EditScreen(wx.Panel):
def init(self, parent, id=-1):
wx.Panel.init(self, parent, id, size=(600, 800))
hbox = wx.BoxSizer(wx.HORIZONTAL)
closeButton = wx.Button(self, -1, ‘Edit’, size=(70, 30))
wx.EVT_BUTTON(self, closeButton.GetId(), parent.OnQuit)
hbox.Add(closeButton, 1)
self.SetSizer(hbox)

class SearchScreen(wx.Panel):
def init(self, parent,
id=-1):
wx.Panel.init(self, parent, id, size=(600, 800))
hbox = wx.BoxSizer(wx.HORIZONTAL)
closeButton = wx.Button(self, -1, ‘Search’, size=(70, 30))
wx.EVT_BUTTON(self, closeButton.GetId(), parent.OnQuit)
hbox.Add(closeButton, 1)
self.SetSizer(hbox)

def main():
app = wx.PySimpleApp()
f = SuperClass()
f.Show(True)
app.MainLoop()

if name == “main”:
main()


Sucker-punch spam with award-winning protection.
Try the free Yahoo! Mail Beta.