Creating an application with wxPython where I could navigate across several pages
Question: I would like to create an application built with wxPyhton where I could
navigate across several pages with two next and previous buttons.

Can you give me real codes examples?


Answer: What you are likely looking for is a wizard. There are several pages on the
wxPython website that talk about how to create one:

  * <https://wiki.wxpython.org/wxWizard>
  * <https://wxpython.org/Phoenix/docs/html/wx.adv.Wizard.html?highlight=wizard>

I have also written on the topic on my blog. You can see how to roll your own
wizard [here](http://www.blog.pythonlibrary.org/2012/07/12/wxpython-how-to-
create-a-generic-wizard/) or create one using the widget that wxPython
provides [here](http://www.blog.pythonlibrary.org/2011/01/27/wxpython-a-
wizard-tutorial/).

Here's a short example:

    
    
    import wx
    import wx.wizard as wiz
    
    ########################################################################
    class TitledPage(wiz.WizardPageSimple):
        """"""
    
        #----------------------------------------------------------------------
        def __init__(self, parent, title):
            """Constructor"""
            wiz.WizardPageSimple.__init__(self, parent)
    
            sizer = wx.BoxSizer(wx.VERTICAL)
            self.SetSizer(sizer)
    
            title = wx.StaticText(self, -1, title)
            title.SetFont(wx.Font(18, wx.SWISS, wx.NORMAL, wx.BOLD))
            sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
            sizer.Add(wx.StaticLine(self, -1), 0, wx.EXPAND|wx.ALL, 5)
    
    #----------------------------------------------------------------------
    def main():
        """"""
        wizard = wx.wizard.Wizard(None, -1, "Simple Wizard")
        page1 = TitledPage(wizard, "Page 1")
        page2 = TitledPage(wizard, "Page 2")
        page3 = TitledPage(wizard, "Page 3")
        page4 = TitledPage(wizard, "Page 4")
    
        wx.wizard.WizardPageSimple.Chain(page1, page2)
        wx.wizard.WizardPageSimple.Chain(page2, page3)
        wx.wizard.WizardPageSimple.Chain(page3, page4)
        wizard.FitToPage(page1)
    
        wizard.RunWizard(page1)
    
        wizard.Destroy()
    
    #----------------------------------------------------------------------
    if __name__ == "__main__":
        app = wx.App(False)
        main()
        app.MainLoop()
    

