wxWizard クラスを使用して単純なインストーラーを作成しようとしています。最初のページ (page0) に 3 つのオプションが必要です
1. Install (click Next goes to page install1)
2. Upgrade (click Next goes to page upgrade1)
3. Remove (click Next goes to page remove1)
OOP (および一般的なプログラミング) の経験がないため、これを行う page0 オブジェクトを作成する方法を理解できません。
install1 の前に page0 を作成した場合: グローバル名 'install1' が定義されていませんpage0の前に install1 を作成した場合: 最大再帰深度を超えました.wizard.htmlGetNext()
: これも理解できないファンキーなメソッドがあります。
助けてください!
import wx
import wx.wizard
class InstallPage_Dyn(wx.wizard.PyWizardPage):
def __init__(self, parent, title):
wx.wizard.PyWizardPage.__init__(self, parent)
self.next = self.prev = None
class InstallPage0(wx.wizard.PyWizardPage):
def __init__(self, parent, title):
wx.wizard.PyWizardPage.__init__(self, parent)
self.next = self.prev = None
self.box = wx.RadioBox (self, -1, 'Choose one of the options below and hit Next\n', choices=['Install','Upgrade','Remove'], style = wx.VERTICAL | wx.EXPAND)
# Set Next button based on user choice
self.box.Bind(wx.EVT_RADIOBOX, self.SetNext(install1))
# Setter and getter methods to specify Next and Previous buttons#
def SetNext(self, next):
userchoice = self.box.GetSelection()
if userchoice == 0:
self.SetNext(install1)
elif userchoice == 1:
self.SetNext(upgrade1)
elif userchoice == 2:
self.SetNext(remove1)
def SetPrev(self, prev):
return self.prev
def GetNext(self):
return self.next
def GetPrev(self):
return self.prev
# Define application and create the wizard
app = wx.App()
wizard = wx.wizard.Wizard(None, -1, "Installer")
wizard.SetPageSize((500,350))
# User selected install. Create the pages
install1 = InstallPage_Dyn(wizard, "Install")
upgrade1 = InstallPage_Dyn(wizard, "Upgrade")
remove1 = InstallPage_Dyn(wizard, "Remove")
# Create page instances
page0 = InstallPage0(wizard, "Installer")
wizard.RunWizard(page0)