 #-*- coding: utf-8 -*-
import	wx
import	wx.wizard as wiz
import	lang

LangCH = '中文'
LangEN = 'English'

#RemoteLinuxGra = 'Boot Remote Linux Machine(s) on Graphic Mode'
#RemoteLinuxTxt = 'Boot Remote Linux Machine(s) on Txt Mode'
#ClonezillaStartSave = 'Start Clonezilla on SAVE mode'
#ClonezillaStartRestore = 'Start Clonezilla on RESTORE mode'
ToDo = 'What You Want To Do ?'

#----------------------------------------------------------------------
def makePageTitle(wizPg, title):
    sizer = wx.BoxSizer(wx.VERTICAL)
    wizPg.SetSizer(sizer)
    title = wx.StaticText(wizPg, -1, title)
    title.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD))
    sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5)
    sizer.Add(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5)
    return sizer

#----------------------------------------------------------------------
class SelectWizardPage(wiz.PyWizardPage):
    def __init__(self, parent, title):
        wiz.PyWizardPage.__init__(self, parent)
        self.next = self.prev = None
        self.sizer = makePageTitle(self, title)

        FunctionList = ['lang.msg_remote_linux_graphic', 'lang.msg_remote_linux_text']
	sizer = wx.BoxSizer(wx.HORIZONTAL)
        choice = wx.RadioBox(self, -1, ToDo, (35,50), (500,150), LangList, 1, wx.RA_SPECIFY_COLS)
        self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, choice)
        choice.SetSelection(0)
        sizer.Add(choice, 0, wx.ALIGN_LEFT|wx.TOP|wx.RIGHT, 40)
        self.SetSizer(sizer)

    def EvtRadioBox(self, event):
	if event.Selection() == 0:
	    

    def SetNext(self, next):
        self.next = next

    def SetPrev(self, prev):
        self.prev = prev

    def GetNext(self):
        return self.next

    def GetPrev(self):
        return self.prev

#----------------------------------------------------------------------
class WizardBasePage(wiz.PyWizardPage):
    def __init__(self, parent, title):
        wiz.PyWizardPage.__init__(self, parent)
        self.next = self.prev = None
        self.sizer = makePageTitle(self, title)

    def SetNext(self, next):
        self.next = next

    def SetPrev(self, prev):
        self.prev = prev

    def GetNext(self):
        return self.next

    def GetPrev(self):
        return self.prev

#----------------------------------------------------------------------
class MainFrame(wx.Frame):
    def	__init__(self, parent, id)
        wx.Frame.__init__(self, parent, id, 'TEST WIZARD', size=(500,400))
        panel  = wx.Panel(self)

        LangList = [LangCH, LangEN]
        sizer = wx.BoxSizer(wx.HORIZONTAL)
        choice = wx.RadioBox(self, -1, ToDo, (35,50), (500,150), LangList,1,wx.RA_SPECIFY_COLS)
        self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, choice)
        choice.SetSelection(0)
        sizer.Add(choice, 0, wx.ALIGN_LEFT|wx.TOP|wx.RIGHT, 40)
        self.SetSizer(sizer)
        btn = wx.Button(self, -1, 'Run Wizard', pos=(400, 300))
        self.Bind(wx.EVT_BUTTON, self.RunWizard, btn)

    def EvtRadioBox(self, event):
        btn = wx.Button(self, -1, 'Run Wizard', pos=(400, 300))
        if event.GetSelection() == 0:
	    os.system("rm -rf lang.py")
	    os.system("cp /home/chris/lang_ch.py /home/chris/lang.py")
            self.Bind(wx.EVT_BUTTON, self.RunWizard, btn)
        if event.GetSelection() == 1:
	    os.system("rm -rf lang.py")
	    os.system("cp /home/chris/lang_en.py /home/chris/lang.py")
            self.Bind(wx.EVT_BUTTON, self.RunWizard, btn)

#--------------------------Wizard Module------------------------------
    def RunWizard(self, evt):
        wizard = wiz.Wizard(self, -1, lang.msg_remote_linux_graphic ,pos = (500,200))

	page1 = SelectWizardPage(wizard, 'page1')
	page2 = WizardBasePage(wizard, 'page2')
	page3 = WizardBasePage(wizard, 'page3')
	self.page1 = page1
	wizard.SetPageSize((500,300))

        page1.SetNext(page2)
        page2.SetPrev(page1)
        page2.SetNext(page3)

        if wizard.RunWizard(page1):
            wx.MessageBox('success', "That's all folks!")
        else:
            wx.MessageBox('cancel', "That's all folks!")

#----------------------------------------------------------------------
    def RemoteLinuxTxtWizard(self, evt):
        wizard = wiz.Wizard(self, -1, lang.msg_remote_linux_text, pos = (500,200))

        page1 = WizardBasePage(wizard, 'page1')
        page2 = WizardBasePage(wizard, 'page2')
        page3 = WizardBasePage(wizard, 'page3')
        self.page1 = page1
        wizard.SetPageSize((500,300))

        page1.SetNext(page2)
        page2.SetPrev(page1)
        page2.SetNext(page3)

        if wizard.RunWizard(page1):
            wx.MessageBox('success', "That's all folks!")
        else:
            wx.MessageBox('cancel', "That's all folks!")

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

def runTest(frame, nb, log):
    testWin = MainFrame(nb, -1, log)
    return testWin

#----------------------------------------------------------------------------
if __name__ == '__main__':
    import sys,os
    import run
    run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:])


#class App(wx.App):

#    def OnInit(self):
#	frame = MainFrame(, id=-1)
#	frame.Show()
#	return True

#app = App()
#app.MainLoop()

