from Screen import Screen
-import string
-
from Screens.HelpMenu import HelpableScreen
-from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_BACKSPACE
+from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_HOME, KEY_END, KEY_0, KEY_DELETE, KEY_BACKSPACE, KEY_OK, KEY_TOGGLEOW, KEY_ASCII, KEY_TIMEOUT, KEY_NUMBERS
+
from Components.Label import Label
from Components.Slider import Slider
from Components.ActionMap import NumberActionMap
timeoutstep = ''
self.wizard[self.lastStep] = {"id": id, "condition": "", "text": "", "timeout": timeout, "timeoutaction": timeoutaction, "timeoutstep": timeoutstep, "list": [], "config": {"screen": None, "args": None, "type": "" }, "code": "", "codeafter": "", "code_async": "", "codeafter_async": "", "nextstep": nextstep}
elif (name == "text"):
- self.wizard[self.lastStep]["text"] = string.replace(str(attrs.get('value')), "\\n", "\n")
+ self.wizard[self.lastStep]["text"] = str(attrs.get('value')).replace("\\n", "\n")
elif (name == "displaytext"):
- self.wizard[self.lastStep]["displaytext"] = string.replace(str(attrs.get('value')), "\\n", "\n")
+ self.wizard[self.lastStep]["displaytext"] = str(attrs.get('value')).replace("\\n", "\n")
elif (name == "list"):
if (attrs.has_key('type')):
if attrs["type"] == "dynamic":
self.disableKeys = False
- self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions"],
+ self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions", "InputAsciiActions"],
{
+ "gotAsciiCode": self.keyGotAscii,
"ok": self.ok,
"back": self.back,
"left": self.left,
if self.updateValues not in self.onShown:
self.onShown.append(self.updateValues)
-
+
if self.showConfig:
if self.wizard[currStep]["config"]["type"] == "dynamic":
eval("self." + self.wizard[currStep]["config"]["evaluation"])()
else:
self.currStep = self.getStepWithID(nextStep)
+ print_now = True
if ((currStep == self.numSteps and self.wizard[currStep]["nextstep"] is None) or self.wizard[currStep]["id"] == "end"): # wizard finished
print "wizard finished"
self.markDone()
self.close()
else:
- self.codeafter=True
+ self.codeafter = True
self.runCode(self.wizard[currStep]["codeafter"])
- async = self.runCode(self.wizard[currStep]["codeafter_async"])
- if self.wizard[currStep]["nextstep"] is not None:
- self.currStep = self.getStepWithID(self.wizard[currStep]["nextstep"])
- if gotoStep is not None:
- self.currStep = self.getStepWithID(gotoStep)
- if not async:
- self.currStep += 1
- self.updateValues()
- print "Now: " + str(self.currStep)
+ self.prevStep = currStep
+ self.gotoStep = gotoStep
+ if not self.runCode(self.wizard[currStep]["codeafter_async"]):
+ self.afterAsyncCode()
else:
- self.onShown.remove(self.updateValues)
- print "Now: " + str(self.currStep+1), "(after async code finished)"
+ if self.updateValues in self.onShown:
+ self.onShown.remove(self.updateValues)
+
+ if print_now:
+ print "Now: " + str(self.currStep)
def ok(self):
print "OK"
# for this. If there is one, please do a more specific check
# and/or a comment in which situation there is no run()
if callable(getattr(self.configInstance, "runAsync", None)):
- self.onShown.remove(self.updateValues)
+ if self.updateValues in self.onShown:
+ self.onShown.remove(self.updateValues)
self.configInstance.runAsync(self.finished)
return
else:
def keyNumberGlobal(self, number):
if (self.wizard[self.currStep]["config"]["screen"] != None):
self.configInstance.keyNumberGlobal(number)
+
+ def keyGotAscii(self):
+ if (self.wizard[self.currStep]["config"]["screen"] != None):
+ self["config"].handleKey(KEY_ASCII)
def left(self):
self.resetCounter()
del self.configInstance["config"]
self.configInstance.doClose()
self.configInstance = None
-
+
self.condition = True
exec (self.wizard[self.currStep]["condition"])
- if self.condition:
+ if not self.condition:
+ self.currStep += 1
+ self.updateValues()
+ else:
+ if self.wizard[self.currStep].has_key("displaytext"):
+ displaytext = self.wizard[self.currStep]["displaytext"]
+ print "set LCD text"
+ for x in self.lcdCallbacks:
+ x(displaytext)
if len(self.stepHistory) == 0 or self.stepHistory[-1] != self.currStep:
self.stepHistory.append(self.currStep)
print "wizard step:", self.wizard[self.currStep]
self.codeafter=False
self.runCode(self.wizard[self.currStep]["code"])
- self.async = self.runCode(self.wizard[self.currStep]["code_async"])
- if self.async:
- self.onShown.remove(self.updateValues)
+ if self.runCode(self.wizard[self.currStep]["code_async"]):
+ if self.updateValues in self.onShown:
+ self.onShown.remove(self.updateValues)
else:
self.afterAsyncCode()
- else:
- self.currStep += 1
- self.updateValues()
def afterAsyncCode(self):
- if self.updateValues not in self.onShown:
+ if not self.updateValues in self.onShown:
self.onShown.append(self.updateValues)
+
if self.codeafter:
+ if self.wizard[self.prevStep]["nextstep"] is not None:
+ self.currStep = self.getStepWithID(self.wizard[self.prevStep]["nextstep"])
+ if self.gotoStep is not None:
+ self.currStep = self.getStepWithID(self.gotoStep)
self.currStep += 1
self.updateValues()
+ print "Now: " + str(self.currStep)
else:
if self.showList:
print "showing list,", self.currStep
self.wizards.append((wizard, precondition, priority))
def getWizards(self):
- list = []
- for x in self.wizards:
- if x[1] == 1: # precondition
- list.append((x[2], x[0]))
- return list
+ # x[1] is precondition
+ return [(x[2], x[0]) for x in self.wizards if x[1] == 1]
wizardManager = WizardManager()