From 1036de712ab59acf11d5012d182cea8734b8412b Mon Sep 17 00:00:00 2001 From: Stefan Pluecken Date: Fri, 9 Dec 2005 00:35:41 +0000 Subject: [PATCH] use startwizard.xml for startwizard-generation --- data/startwizard.xml | 42 ++++++++++++++++ lib/python/Screens/Wizard.py | 97 +++++++++++++++++++++++++----------- 2 files changed, 110 insertions(+), 29 deletions(-) create mode 100644 data/startwizard.xml diff --git a/data/startwizard.xml b/data/startwizard.xml new file mode 100644 index 00000000..13799a2c --- /dev/null +++ b/data/startwizard.xml @@ -0,0 +1,42 @@ + + + + + + + + + + + +self["arrowdown"].moveTo(557, 200, 10) +self["arrowup"].moveTo(557, 355, 10) +self["arrowdown"].startMoving() +self["arrowup"].startMoving() + + + + + + +self["arrowup"].moveTo(740, 355, 10) +self["arrowup"].startMoving() +self["arrowdown"].clearPath(True) +self["arrowdown"].addMovePoint(510, 300, 10) +self["arrowdown"].addMovePoint(610, 300, 10) +self["arrowdown"].startMoving() +self["config"].l.setList(self.scanSetupDialog["config"].list) + + + + + +self["arrowdown"].moveTo(740, 200, 10) +self["arrowup"].moveTo(740, 355, 10) +self["arrowdown"].startMoving() +self["arrowup"].startMoving() +self["rc"].moveTo(500, 600, 5) +self["rc"].startMoving() + + + diff --git a/lib/python/Screens/Wizard.py b/lib/python/Screens/Wizard.py index 818d99ec..8922380d 100644 --- a/lib/python/Screens/Wizard.py +++ b/lib/python/Screens/Wizard.py @@ -7,6 +7,11 @@ from Components.ActionMap import HelpableActionMap from Components.config import config, configElementBoolean from Components.Pixmap import * from Components.MenuList import MenuList +from Components.ConfigList import ConfigList +from Screens.ScanSetup import ScanSimple + +from xml.sax import make_parser +from xml.sax.handler import ContentHandler config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1); @@ -16,42 +21,78 @@ class WelcomeWizard(Screen, HelpableScreen): + - + """ - - text = [_("Hello User.\n\nThis start-wizard will guide you through the basic setup of your Dreambox.\n\nPress the OK button on your remote control to move to the next step."), - _("You can use the Up and Down buttons on your remote control to select your choice.\n\nWhat do you want to do?"), - _("Blub")] - - listEntries = [[], - ["Use wizard to set up basic features", "Exit wizard"], - []] + class parseWizard(ContentHandler): + def __init__(self, wizard): + self.isPointsElement, self.isReboundsElement = 0, 0 + self.wizard = wizard + self.currContent = "" + + def startElement(self, name, attrs): + self.currContent = name + if (name == "step"): + self.lastStep = int(attrs.get('number')) + self.wizard[self.lastStep] = {"text": "", "list": [], "config": 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"] = eval(str(attrs.get('screen'))) + + 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 = {} + print self.wizard + parser = make_parser() + print "Reading startwizard.xml" + wizardHandler = self.parseWizard(self.wizard) + parser.setContentHandler(wizardHandler) + parser.parse('/usr/share/enigma2/startwizard.xml') + + print self.wizard + + self.numSteps = 4 + self.currStep = 1 self["text"] = Label() - self["rc"] = Pixmap() + self["rc"] = MovingPixmap() self["arrowdown"] = MovingPixmap() self["arrowdown"].moveTo(557, 232, 10) self["arrowup"] = MovingPixmap() + self["rc"].moveTo(500, 50, 10) + self["config"] = ConfigList([]) self.onShown.append(self["arrowdown"].startMoving) + self.onShown.append(self["rc"].startMoving) self["step"] = Label() self["stepslider"] = Slider(1, self.numSteps) + #self.scanSetupDialog = self.session.instantiateDialog(ScanSimple) + self.list = [] #list.append(("Use wizard to set up basic features", None)) #list.append(("Exit wizard", None)) @@ -65,16 +106,27 @@ 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.list = [] + + self["text"].setText(self.wizard[self.currStep]["text"]) - if (len(self.listEntries[self.currStep - 1]) > 0): - for x in self.listEntries[self.currStep - 1]: + 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"] != None): + self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]) + 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; @@ -83,19 +135,6 @@ class WelcomeWizard(Screen, HelpableScreen): else: self.currStep += 1 self.updateValues() - - if (self.currStep == 2): - self["arrowdown"].moveTo(557, 200, 10) - self["arrowup"].moveTo(557, 355, 10) - self["arrowdown"].startMoving() - self["arrowup"].startMoving() - if (self.currStep == 3): - self["arrowup"].moveTo(740, 355, 10) - self["arrowup"].startMoving() - self["arrowdown"].clearPath(True) - self["arrowdown"].addMovePoint(510, 300, 10) - self["arrowdown"].addMovePoint(610, 300, 10) - self["arrowdown"].startMoving() def listActiveWizards(): wizards = [ ] -- 2.30.2