Examples of wx.Wizard that I found used explicit names for the pages.
Using eval() in a list comprehension, I am able to go through the imported modules by name and call create() in order to get a page instance. Neat trick, I think...
- #Boa:Wizard:Wizard1
-
-
import wx
-
import wx.wizard
-
-
import SetupWizardPage1
-
import SetupWizardPage2
-
-
nSetupWizardPages = 2
-
-
def create(parent):
-
return Wizard1(parent)
-
-
[wxID_WIZARD1] = [wx.NewId() for _init_ctrls in range(1)]
-
-
class Wizard1(wx.wizard.Wizard):
-
def _init_ctrls(self, prnt):
-
# generated method, don't edit
-
wx.wizard.Wizard.__init__(self, bitmap=wx.NullBitmap, id=wxID_WIZARD1, parent=prnt,
-
pos=wx.Point(459, 285), title='HETAP Data Collection Setup')
-
-
def __init__(self, parent):
-
self._init_ctrls(parent)
-
-
## the old way
-
## page1 = SetupWizardPage1.ParkListPage(self)
-
## self.page1 = page1
-
## page2 = SetupWizardPage2.TrailListPage(self)
-
-
## I had to add create() to the SimpleWizardPage generated by Boa
-
self.pages = pages = [eval("SetupWizardPage%d.create(self)" %i)
-
for i in range(1, nSetupWizardPages + 1)]
-
-
self.FitToPage(pages[0])
-
-
## Once they're in a list, chaining becomes a snap
-
for i in range(nSetupWizardPages - 1):
-
# Use the convenience Chain function to connect the pages in a loop
-
wx.wizard.WizardPageSimple_Chain(pages[i], pages[i + 1])
-
-
-
self.GetPageAreaSizer().Add(pages[0])
-
-
def GetFirstPage(self):
-
"""I make the wizard responsible for creating the pages, so the caller must
-
be able to get the first page for the Wizard.Run() argument"""
-
return self.pages[0]