1 | #-*- coding: utf-8 -*- |
---|
2 | import wx |
---|
3 | import wx.wizard as wiz |
---|
4 | import lang |
---|
5 | |
---|
6 | LangCH = '中文' |
---|
7 | LangEN = 'English' |
---|
8 | |
---|
9 | #RemoteLinuxGra = 'Boot Remote Linux Machine(s) on Graphic Mode' |
---|
10 | #RemoteLinuxTxt = 'Boot Remote Linux Machine(s) on Txt Mode' |
---|
11 | #ClonezillaStartSave = 'Start Clonezilla on SAVE mode' |
---|
12 | #ClonezillaStartRestore = 'Start Clonezilla on RESTORE mode' |
---|
13 | ToDo = 'What You Want To Do ?' |
---|
14 | |
---|
15 | #---------------------------------------------------------------------- |
---|
16 | def makePageTitle(wizPg, title): |
---|
17 | sizer = wx.BoxSizer(wx.VERTICAL) |
---|
18 | wizPg.SetSizer(sizer) |
---|
19 | title = wx.StaticText(wizPg, -1, title) |
---|
20 | title.SetFont(wx.Font(12, wx.SWISS, wx.NORMAL, wx.BOLD)) |
---|
21 | sizer.Add(title, 0, wx.ALIGN_CENTRE|wx.ALL, 5) |
---|
22 | sizer.Add(wx.StaticLine(wizPg, -1), 0, wx.EXPAND|wx.ALL, 5) |
---|
23 | return sizer |
---|
24 | |
---|
25 | #---------------------------------------------------------------------- |
---|
26 | class SelectWizardPage(wiz.PyWizardPage): |
---|
27 | def __init__(self, parent, title): |
---|
28 | wiz.PyWizardPage.__init__(self, parent) |
---|
29 | self.next = self.prev = None |
---|
30 | self.sizer = makePageTitle(self, title) |
---|
31 | |
---|
32 | FunctionList = ['lang.msg_remote_linux_graphic', 'lang.msg_remote_linux_text'] |
---|
33 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
34 | choice = wx.RadioBox(self, -1, ToDo, (35,50), (500,150), LangList, 1, wx.RA_SPECIFY_COLS) |
---|
35 | self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, choice) |
---|
36 | choice.SetSelection(0) |
---|
37 | sizer.Add(choice, 0, wx.ALIGN_LEFT|wx.TOP|wx.RIGHT, 40) |
---|
38 | self.SetSizer(sizer) |
---|
39 | |
---|
40 | def EvtRadioBox(self, event): |
---|
41 | if event.Selection() == 0: |
---|
42 | |
---|
43 | |
---|
44 | def SetNext(self, next): |
---|
45 | self.next = next |
---|
46 | |
---|
47 | def SetPrev(self, prev): |
---|
48 | self.prev = prev |
---|
49 | |
---|
50 | def GetNext(self): |
---|
51 | return self.next |
---|
52 | |
---|
53 | def GetPrev(self): |
---|
54 | return self.prev |
---|
55 | |
---|
56 | #---------------------------------------------------------------------- |
---|
57 | class WizardBasePage(wiz.PyWizardPage): |
---|
58 | def __init__(self, parent, title): |
---|
59 | wiz.PyWizardPage.__init__(self, parent) |
---|
60 | self.next = self.prev = None |
---|
61 | self.sizer = makePageTitle(self, title) |
---|
62 | |
---|
63 | def SetNext(self, next): |
---|
64 | self.next = next |
---|
65 | |
---|
66 | def SetPrev(self, prev): |
---|
67 | self.prev = prev |
---|
68 | |
---|
69 | def GetNext(self): |
---|
70 | return self.next |
---|
71 | |
---|
72 | def GetPrev(self): |
---|
73 | return self.prev |
---|
74 | |
---|
75 | #---------------------------------------------------------------------- |
---|
76 | class MainFrame(wx.Frame): |
---|
77 | def __init__(self, parent, id) |
---|
78 | wx.Frame.__init__(self, parent, id, 'TEST WIZARD', size=(500,400)) |
---|
79 | panel = wx.Panel(self) |
---|
80 | |
---|
81 | LangList = [LangCH, LangEN] |
---|
82 | sizer = wx.BoxSizer(wx.HORIZONTAL) |
---|
83 | choice = wx.RadioBox(self, -1, ToDo, (35,50), (500,150), LangList,1,wx.RA_SPECIFY_COLS) |
---|
84 | self.Bind(wx.EVT_RADIOBOX, self.EvtRadioBox, choice) |
---|
85 | choice.SetSelection(0) |
---|
86 | sizer.Add(choice, 0, wx.ALIGN_LEFT|wx.TOP|wx.RIGHT, 40) |
---|
87 | self.SetSizer(sizer) |
---|
88 | btn = wx.Button(self, -1, 'Run Wizard', pos=(400, 300)) |
---|
89 | self.Bind(wx.EVT_BUTTON, self.RunWizard, btn) |
---|
90 | |
---|
91 | def EvtRadioBox(self, event): |
---|
92 | btn = wx.Button(self, -1, 'Run Wizard', pos=(400, 300)) |
---|
93 | if event.GetSelection() == 0: |
---|
94 | os.system("rm -rf lang.py") |
---|
95 | os.system("cp /home/chris/lang_ch.py /home/chris/lang.py") |
---|
96 | self.Bind(wx.EVT_BUTTON, self.RunWizard, btn) |
---|
97 | if event.GetSelection() == 1: |
---|
98 | os.system("rm -rf lang.py") |
---|
99 | os.system("cp /home/chris/lang_en.py /home/chris/lang.py") |
---|
100 | self.Bind(wx.EVT_BUTTON, self.RunWizard, btn) |
---|
101 | |
---|
102 | #--------------------------Wizard Module------------------------------ |
---|
103 | def RunWizard(self, evt): |
---|
104 | wizard = wiz.Wizard(self, -1, lang.msg_remote_linux_graphic ,pos = (500,200)) |
---|
105 | |
---|
106 | page1 = SelectWizardPage(wizard, 'page1') |
---|
107 | page2 = WizardBasePage(wizard, 'page2') |
---|
108 | page3 = WizardBasePage(wizard, 'page3') |
---|
109 | self.page1 = page1 |
---|
110 | wizard.SetPageSize((500,300)) |
---|
111 | |
---|
112 | page1.SetNext(page2) |
---|
113 | page2.SetPrev(page1) |
---|
114 | page2.SetNext(page3) |
---|
115 | |
---|
116 | if wizard.RunWizard(page1): |
---|
117 | wx.MessageBox('success', "That's all folks!") |
---|
118 | else: |
---|
119 | wx.MessageBox('cancel', "That's all folks!") |
---|
120 | |
---|
121 | #---------------------------------------------------------------------- |
---|
122 | def RemoteLinuxTxtWizard(self, evt): |
---|
123 | wizard = wiz.Wizard(self, -1, lang.msg_remote_linux_text, pos = (500,200)) |
---|
124 | |
---|
125 | page1 = WizardBasePage(wizard, 'page1') |
---|
126 | page2 = WizardBasePage(wizard, 'page2') |
---|
127 | page3 = WizardBasePage(wizard, 'page3') |
---|
128 | self.page1 = page1 |
---|
129 | wizard.SetPageSize((500,300)) |
---|
130 | |
---|
131 | page1.SetNext(page2) |
---|
132 | page2.SetPrev(page1) |
---|
133 | page2.SetNext(page3) |
---|
134 | |
---|
135 | if wizard.RunWizard(page1): |
---|
136 | wx.MessageBox('success', "That's all folks!") |
---|
137 | else: |
---|
138 | wx.MessageBox('cancel', "That's all folks!") |
---|
139 | |
---|
140 | #---------------------------------------------------------------------- |
---|
141 | |
---|
142 | def runTest(frame, nb, log): |
---|
143 | testWin = MainFrame(nb, -1, log) |
---|
144 | return testWin |
---|
145 | |
---|
146 | #---------------------------------------------------------------------------- |
---|
147 | if __name__ == '__main__': |
---|
148 | import sys,os |
---|
149 | import run |
---|
150 | run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) |
---|
151 | |
---|
152 | |
---|
153 | #class App(wx.App): |
---|
154 | |
---|
155 | # def OnInit(self): |
---|
156 | # frame = MainFrame(, id=-1) |
---|
157 | # frame.Show() |
---|
158 | # return True |
---|
159 | |
---|
160 | #app = App() |
---|
161 | #app.MainLoop() |
---|
162 | |
---|