X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/7ee8589392aca17526ca30264689f204afc9646a..a4332bd8d55eb4b54972f64c91aefd42f388de52:/lib/python/Screens/Wizard.py?ds=sidebyside diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index b199634d..f0d99a9e 100644 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -5,41 +5,89 @@ from Components.Label import Label from Components.Slider import Slider from Components.ActionMap import HelpableActionMap from Components.config import config, configElementBoolean -from Components.Pixmap import Pixmap +from Components.Pixmap import * +from Components.MenuList import MenuList +from Components.ConfigList import ConfigList + +from xml.sax import make_parser +from xml.sax.handler import ContentHandler config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1); class WelcomeWizard(Screen, HelpableScreen): skin = """ - - + + + + - - + + + """ - - text = [_("Hello User.\n\nThis start-wizard will guide you through the basic setup of your Dreambox."), - _("Bla"), - _("Blub")] + class parseWizard(ContentHandler): + def __init__(self, wizard): + self.isPointsElement, self.isReboundsElement = 0, 0 + self.wizard = wizard + self.currContent = "" + + def startElement(self, name, attrs): + print name + self.currContent = name + if (name == "step"): + self.lastStep = int(attrs.get('number')) + self.wizard[self.lastStep] = {"text": "", "list": [], "config": {"screen": None, "args": None }, "code": ""} + elif (name == "text"): + self.wizard[self.lastStep]["text"] = str(attrs.get('value')) + elif (name == "listentry"): + self.wizard[self.lastStep]["list"].append(str(attrs.get('caption'))) + elif (name == "config"): + exec "from Screens." + str(attrs.get('module')) + " import *" + self.wizard[self.lastStep]["config"]["screen"] = eval(str(attrs.get('screen'))) + if (attrs.has_key('args')): + print "has args" + self.wizard[self.lastStep]["config"]["args"] = str(attrs.get('args')) + def endElement(self, name): + self.currContent = "" + if name == 'code': + self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"].strip() + + def characters(self, ch): + if self.currContent == "code": + self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"] + ch + def __init__(self, session): self.skin = WelcomeWizard.skin - self.numSteps = 3 - self.currStep = 1 Screen.__init__(self, session) HelpableScreen.__init__(self) + self.wizard = {} + parser = make_parser() + print "Reading startwizard.xml" + wizardHandler = self.parseWizard(self.wizard) + parser.setContentHandler(wizardHandler) + parser.parse('/usr/share/enigma2/startwizard.xml') + + self.numSteps = len(self.wizard) + self.currStep = 1 self["text"] = Label() - self["rc"] = Pixmap() - self["arrowdown"] = Pixmap() + self["rc"] = MovingPixmap() + self["arrowdown"] = MovingPixmap() + self["arrowup"] = MovingPixmap() + + self["config"] = ConfigList([]) self["step"] = Label() self["stepslider"] = Slider(1, self.numSteps) + + self.list = [] + self["list"] = MenuList(self.list) self.updateValues() @@ -49,10 +97,32 @@ class WelcomeWizard(Screen, HelpableScreen): }) def updateValues(self): - self["text"].setText(self.text[self.currStep - 1]) self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps)) self["stepslider"].setValue(self.currStep) + + self["text"].setText(self.wizard[self.currStep]["text"]) + + self.list = [] + if (len(self.wizard[self.currStep]["list"]) > 0): + for x in self.wizard[self.currStep]["list"]: + self.list.append((x, None)) + self["list"].l.setList(self.list) + if (self.wizard[self.currStep]["config"]["screen"] != None): + print 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) + else: + self["config"].l.setList([]) + + if self.wizard[self.currStep]["code"] != "": + print self.wizard[self.currStep]["code"] + exec(self.wizard[self.currStep]["code"]) + def ok(self): if (self.currStep == self.numSteps): # wizard finished config.misc.firstrun.value = 0;