# -*- coding: utf-8 -*-

import wx
import wx.xrc as xrc
import wx.wizard as wiz

class WizardPageOne:
    def __init__(self, parent, page):
        self.pg = xrc.XRCCTRL(parent, page)

        self.rb = xrc.XRCCTRL(self.pg, 'radioBox')

    def GetSelection(self):
        self.rb.GetSelection()


class WizardPageTwo:
    def __init__(self, parent, page):
        self.pg = xrc.XRCCTRL(parent, page)

        self.rb = xrc.XRCCTRL(self.pg, 'radioBox')

    def GetSelection(self):
        self.rb.GetSelection()


class WizardPageThree:
    def __init__(self, parent, page, resource):
        self.resource = resource
        self.parent = parent
        self.pageList = ['NeckPanel', 'ShouldersPanel', 'UpperArmsPanel']
        self.pg = xrc.XRCCTRL(parent, page)

    def GetSelection(self):
        self.rb.GetSelection()

    def SetPage(self, selection):
        self.page = self.resource.LoadPanel(self.pg, self.pageList[selection])
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(self.page, 2, wx.EXPAND)
        self.pg.SetSizer(sizer)
        self.rb = xrc.XRCCTRL(self.page, 'radioBox')


def ExerciseWizard():
    # Load resource file with wizard pages
    resource = xrc.XmlResource('wizard.xrc')

    # Create the wizard and the pages
    wizard = resource.LoadObject(None, 'ExerciseWizard', 'wxWizard')

    page1 = WizardPageOne(wizard, 'StepOne')
    page2 = WizardPageTwo(wizard, 'StepTwo')
    page3 = WizardPageThree(wizard, "StepThree", resource)

    # Set the initial order of the pages
    page1.pg.SetNext(page2.pg)
    page2.pg.SetPrev(page1.pg)
    page2.pg.SetNext(page3.pg)
    page3.pg.SetPrev(page2.pg)

    wizard.FitToPage(page1.pg)
    if wizard.RunWizard(page1.pg):
        wx.MessageBox("Wizard completed successfully", "That's all folks!")
    else:
        wx.MessageBox("Wizard was cancelled", "That's all folks!")
    wizard.Destroy()


if __name__ == '__main__':
    app = wx.App()
    ExerciseWizard()
    app.MainLoop()
