+ def right(self):
+ if (self.wizard[self.currStep]["config"]["screen"] != None):
+ self.configInstance.keyRight()
+ print "right"
+
+ def up(self):
+ if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
+ self["config"].instance.moveSelection(self["config"].instance.moveUp)
+ elif (self.showList and len(self.wizard[self.currStep]["list"]) > 0):
+ self["list"].instance.moveSelection(self["list"].instance.moveUp)
+ print "up"
+
+ def down(self):
+ if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None):
+ self["config"].instance.moveSelection(self["config"].instance.moveDown)
+ elif (self.showList and len(self.wizard[self.currStep]["list"]) > 0):
+ self["list"].instance.moveSelection(self["list"].instance.moveDown)
+ print "down"
+
+ def runCode(self, code):
+ if code != "":
+ print "code", code
+ exec(code)
+
+ def updateValues(self):
+ print "Updating values in step " + str(self.currStep)
+
+ self.stepHistory.append(self.currStep)
+
+ self.condition = True
+ exec (self.wizard[self.currStep]["condition"])
+ if self.condition:
+ if self.showSteps:
+ self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
+ if self.showStepSlider:
+ self["stepslider"].setValue(self.currStep)
+
+ print "wizard text", _(self.wizard[self.currStep]["text"])
+ self["text"].setText(_(self.wizard[self.currStep]["text"]))
+
+ self.runCode(self.wizard[self.currStep]["code"])
+
+ if self.showList:
+ self["list"].instance.setZPosition(1)
+ self.list = []
+ if (len(self.wizard[self.currStep]["list"]) > 0):
+ self["list"].instance.setZPosition(2)
+ for x in self.wizard[self.currStep]["list"]:
+ self.list.append((_(x[0]), None))
+ self["list"].l.setList(self.list)
+
+ if self.showConfig:
+ self["config"].instance.setZPosition(1)
+ if (self.wizard[self.currStep]["config"]["screen"] != None):
+ if self.wizard[self.currStep]["config"]["type"] == "standalone":
+ print "Type is standalone"
+ self.session.openWithCallback(self.ok, self.wizard[self.currStep]["config"]["screen"])
+ else:
+ self["config"].instance.setZPosition(2)
+ print "wizard screen", self.wizard[self.currStep]["config"]["screen"]
+ if self.wizard[self.currStep]["config"]["args"] == None:
+ self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
+ else:
+ self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
+ self["config"].l.setList(self.configInstance["config"].list)
+ self.configInstance["config"] = self["config"]
+ else:
+ self["config"].l.setList([])
+ else: # condition false
+ self.currStep += 1
+ self.updateValues()
+
+class WizardManager:
+ def __init__(self):
+ self.wizards = []
+
+ def registerWizard(self, wizard, precondition):
+ self.wizards.append((wizard, precondition))
+
+ def getWizards(self):
+ list = []
+ for x in self.wizards:
+ if x[1] == 1: # precondition
+ list.append(x[0])
+ return list
+
+wizardManager = WizardManager()