X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/bdbf663b67d46f79ba2163f6b7df377a63218092..90a6f5184efbee4252e015a82aecd296749bcad3:/lib/python/Screens/Wizard.py diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index 9c9cbd30..9f87ee31 100644 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -3,7 +3,7 @@ from Screen import Screen import string from Screens.HelpMenu import HelpableScreen -from Components.config import config, KEY_LEFT, KEY_RIGHT +from Components.config import config, KEY_LEFT, KEY_RIGHT, KEY_DELETE, KEY_BACKSPACE from Components.Label import Label from Components.Slider import Slider from Components.ActionMap import NumberActionMap @@ -45,7 +45,7 @@ class WizardSummary(Screen): def setText(self, text): self["text"].setText(text) -class Wizard(Screen, HelpableScreen): +class Wizard(Screen): def createSummary(self): print "WizardCreateSummary" return WizardSummary @@ -105,7 +105,10 @@ class Wizard(Screen, HelpableScreen): type = str(attrs.get('type')) self.wizard[self.lastStep]["config"]["type"] = type if type == "ConfigList" or type == "standalone": - exec "from Screens." + str(attrs.get('module')) + " import *" + try: + exec "from Screens." + str(attrs.get('module')) + " import *" + except: + exec "from " + str(attrs.get('module')) + " import *" self.wizard[self.lastStep]["config"]["screen"] = eval(str(attrs.get('screen'))) if (attrs.has_key('args')): @@ -147,7 +150,6 @@ class Wizard(Screen, HelpableScreen): def __init__(self, session, showSteps = True, showStepSlider = True, showList = True, showConfig = True): Screen.__init__(self, session) - HelpableScreen.__init__(self) self.stepHistory = [] @@ -178,7 +180,7 @@ class Wizard(Screen, HelpableScreen): self["text"] = Label() if showConfig: - self["config"] = ConfigList([]) + self["config"] = ConfigList([], session = session) if self.showSteps: self["step"] = Label() @@ -200,7 +202,7 @@ class Wizard(Screen, HelpableScreen): self.disableKeys = False - self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions"], + self["actions"] = NumberActionMap(["WizardActions", "NumberActions", "ColorActions", "SetupActions"], { "ok": self.ok, "back": self.back, @@ -212,6 +214,8 @@ class Wizard(Screen, HelpableScreen): "green": self.green, "yellow": self.yellow, "blue":self.blue, + "deleteBackward": self.deleteBackward, + "deleteForward": self.deleteForward, "1": self.keyNumberGlobal, "2": self.keyNumberGlobal, "3": self.keyNumberGlobal, @@ -240,6 +244,22 @@ class Wizard(Screen, HelpableScreen): print "blue" pass + def deleteForward(self): + self.resetCounter() + if (self.wizard[self.currStep]["config"]["screen"] != None): + self.configInstance.keyDelete() + elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"): + self["config"].handleKey(KEY_DELETE) + print "deleteForward" + + def deleteBackward(self): + self.resetCounter() + if (self.wizard[self.currStep]["config"]["screen"] != None): + self.configInstance.keyBackspace() + elif (self.wizard[self.currStep]["config"]["type"] == "dynamic"): + self["config"].handleKey(KEY_BACKSPACE) + print "deleteBackward" + def setLCDTextCallback(self, callback): self.lcdCallbacks.append(callback) @@ -282,7 +302,7 @@ class Wizard(Screen, HelpableScreen): if self.showConfig: if self.wizard[currStep]["config"]["type"] == "dynamic": eval("self." + self.wizard[currStep]["config"]["evaluation"])() - + if self.showList: if (len(self.wizard[currStep]["evaluatedlist"]) > 0): print "current:", self["list"].current @@ -381,7 +401,7 @@ class Wizard(Screen, HelpableScreen): self.resetCounter() if (self.showConfig and self.wizard[self.currStep]["config"]["screen"] != None): - self["config"].instance.moveSelection(self["config"].instance.moveUp) + self["config"].instance.moveSelection(self["config"].instance.moveUp) elif (self.showList and len(self.wizard[self.currStep]["evaluatedlist"]) > 0): if self.wizard[self.currStep].has_key("onselect"): self.selection = self["list"].current[-1] @@ -396,8 +416,11 @@ class Wizard(Screen, HelpableScreen): print "code", code exec(code) + def getTranslation(self, text): + return _(text) + def updateText(self, firstset = False): - text = _(self.wizard[self.currStep]["text"]) + text = self.getTranslation(self.wizard[self.currStep]["text"]) if text.find("[timeout]") != -1: text = text.replace("[timeout]", str(self.timeoutCounter)) self["text"].setText(text) @@ -417,6 +440,8 @@ class Wizard(Screen, HelpableScreen): self.timeoutTimer.stop() if self.configInstance is not None: + # remove callbacks + self.configInstance["config"].onSelectionChanged = [] del self.configInstance["config"] self.configInstance.doClose() self.configInstance = None @@ -429,7 +454,7 @@ class Wizard(Screen, HelpableScreen): print "wizard step:", self.wizard[self.currStep] if self.showSteps: - self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps)) + self["step"].setText(self.getTranslation("Step ") + str(self.currStep) + "/" + str(self.numSteps)) if self.showStepSlider: self["stepslider"].setValue(self.currStep) @@ -437,7 +462,7 @@ class Wizard(Screen, HelpableScreen): self.resetCounter() self.timeoutTimer.start(1000) - print "wizard text", _(self.wizard[self.currStep]["text"]) + print "wizard text", self.getTranslation(self.wizard[self.currStep]["text"]) self.updateText(firstset = True) if self.wizard[self.currStep].has_key("displaytext"): displaytext = self.wizard[self.currStep]["displaytext"] @@ -471,7 +496,7 @@ class Wizard(Screen, HelpableScreen): 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]), x[1])) + self.list.append((self.getTranslation(x[0]), x[1])) self.wizard[self.currStep]["evaluatedlist"] = self.list self["list"].list = self.list self["list"].index = 0 @@ -498,7 +523,9 @@ class Wizard(Screen, HelpableScreen): 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"].destroy() + print "clearConfigList", self.configInstance["config"], self["config"] self.configInstance["config"] = self["config"] + print "clearConfigList", self.configInstance["config"], self["config"] else: self["config"].l.setList([]) else: