1 # -*- coding: UTF-8 -*-
2 # vim: expandtab sw=4 ts=4 sts=4:
7 __author__
= 'Michal Čihař'
8 __email__
= 'michal@cihar.com'
10 Copyright © 2003 - 2009 Michal Čihař
12 This program is free software; you can redistribute it and/or modify it
13 under the terms of the GNU General Public License version 2 as published by
14 the Free Software Foundation.
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
21 You should have received a copy of the GNU General Public License along with
22 this program; if not, write to the Free Software Foundation, Inc.,
23 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
31 class SimplePage(wx
.wizard
.PyWizardPage
):
33 Simple wizard page with unlimited rows of text.
35 def __init__(self
, parent
, titletext
, bodytext
= None, detailtexts
= None):
36 wx
.wizard
.PyWizardPage
.__init
__(self
, parent
)
38 self
.sizer
= wx
.BoxSizer(wx
.VERTICAL
)
39 self
.SetSizer(self
.sizer
)
40 title
= wx
.StaticText(self
, -1, titletext
)
41 title
.SetFont(wx
.Font(18, wx
.SWISS
, wx
.NORMAL
, wx
.BOLD
))
42 self
.sizer
.Add(title
, 0, wx
.ALIGN_CENTRE|wx
.ALL
, 5)
43 self
.sizer
.Add(wx
.StaticLine(self
, -1), 0, wx
.EXPAND|wx
.ALL
, 5)
46 if bodytext
is not None:
47 body
= wx
.StaticText(self
, -1, bodytext
)
49 self
.sizer
.Add(body
, 0, wx
.ALL
, 5)
50 if detailtexts
is not None:
51 for row
in detailtexts
:
52 detail
= wx
.StaticText(self
, -1, row
)
54 self
.sizer
.Add(detail
, 0, wx
.ALL
, 5)
56 def SetNext(self
, next
):
59 def SetPrev(self
, prev
):
68 def Activated(self
, evt
):
70 Executed when page is being activated.
74 def Blocked(self
, evt
):
76 Executed when page is about to be switched. Switching can be
77 blocked by returning True.
81 def Cancel(self
, evt
):
83 Executed when wizard is about to be canceled. Canceling can be
84 blocked by returning False.
88 class ChoicePage(SimplePage
):
90 Page offering choice of several values and allowing to automatically
91 select next page according to choice.
93 def __init__(self
, parent
, title
, text
, choices
, helps
, nexts
= None, nonetext
='', extratext
= None):
94 Wammu
.Wizard
.SimplePage
.__init
__(self
, parent
, title
, extratext
)
95 self
.type_rb
= wx
.RadioBox(self
, -1, text
,
101 self
.Bind(wx
.EVT_RADIOBOX
, self
.OnTypeChange
, self
.type_rb
)
102 self
.sizer
.Add(self
.type_rb
, 0, wx
.ALL
, 5)
104 self
.body
= wx
.StaticText(self
, -1, self
.texts
[0])
106 self
.body
= wx
.StaticText(self
, -1, nonetext
)
108 self
.sizer
.Add(self
.body
, 0, wx
.ALL
, 5)
110 def OnTypeChange(self
, evt
):
112 self
.body
.SetLabel(self
.texts
[evt
.GetSelection()])
115 self
.body
.SetLabel('')
119 return self
.type_rb
.GetSelection()
122 if self
.nexts
is None or len(self
.nexts
) == 0:
124 return self
.nexts
[self
.type_rb
.GetSelection()]
126 class InputPage(SimplePage
):
128 Page offering text control input.
130 def __init__(self
, parent
, title
, text
, choices
= None, help = ''):
131 Wammu
.Wizard
.SimplePage
.__init
__(self
, parent
, title
, text
)
132 if type(choices
) == str:
133 self
.edit
= wx
.TextCtrl(self
, -1, choices
, size
= (300, -1))
135 self
.edit
= wx
.ComboBox(self
, -1, '', choices
= choices
, size
= (300, -1))
136 self
.sizer
.Add(self
.edit
, 0, wx
.ALL
, 5)
137 self
.body
= wx
.StaticText(self
, -1, help)
139 self
.sizer
.Add(self
.body
, 0, wx
.ALL
, 5)
141 class MultiInputPage(SimplePage
):
143 Page offering several text control inputs.
145 def __init__(self
, parent
, title
, texts
, choices
):
146 Wammu
.Wizard
.SimplePage
.__init
__(self
, parent
, title
)
148 for i
in range(len(texts
)):
149 body
= wx
.StaticText(self
, -1, texts
[i
])
151 self
.sizer
.Add(body
, 0, wx
.ALL
, 5)
152 self
.edits
[i
] = wx
.ComboBox(self
, -1, '', choices
= choices
[i
], size
= (300, -1))
153 self
.sizer
.Add(self
.edits
[i
], 0, wx
.ALL
, 5)
155 class TextPage(SimplePage
):
157 Page offering big text control.
159 def __init__(self
, parent
, title
, text
):
160 Wammu
.Wizard
.SimplePage
.__init
__(self
, parent
, title
, text
)
161 self
.edit
= wx
.TextCtrl(self
, -1, '', style
= wx
.TE_MULTILINE | wx
.TE_READONLY
)
162 self
.sizer
.Add(self
.edit
, 1, wx
.ALL | wx
.EXPAND
, 5)