1 from Screen import Screen
3 from Screens.HelpMenu import HelpableScreen
4 from Components.Label import Label
5 from Components.Slider import Slider
6 from Components.ActionMap import HelpableActionMap
7 from Components.config import config, configElementBoolean
8 from Components.Pixmap import *
9 from Components.MenuList import MenuList
10 from Components.ConfigList import ConfigList
12 from xml.sax import make_parser
13 from xml.sax.handler import ContentHandler
15 config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1);
17 class WelcomeWizard(Screen, HelpableScreen):
20 <screen position="0,0" size="720,560" title="Welcome..." flags="wfNoBorder" >
21 <widget name="text" position="50,100" size="440,200" font="Arial;23" />
22 <widget name="list" position="50,300" size="440,200" />
23 <widget name="config" position="50,300" zPosition="100" size="440,200" />
24 <widget name="step" position="50,50" size="440,25" font="Arial;23" />
25 <widget name="stepslider" position="50,500" zPosition="1" size="440,20" backgroundColor="dark" />
26 <widget name="rc" pixmap="/usr/share/enigma2/rc.png" position="500,600" size="154,475" transparent="1" alphatest="on"/>
27 <widget name="arrowdown" pixmap="/usr/share/enigma2/arrowdown.png" position="0,0" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
28 <widget name="arrowup" pixmap="/usr/share/enigma2/arrowup.png" position="-100,-100" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
31 class parseWizard(ContentHandler):
32 def __init__(self, wizard):
33 self.isPointsElement, self.isReboundsElement = 0, 0
37 def startElement(self, name, attrs):
39 self.currContent = name
41 self.lastStep = int(attrs.get('number'))
42 self.wizard[self.lastStep] = {"text": "", "list": [], "config": {"screen": None, "args": None }, "code": ""}
43 elif (name == "text"):
44 self.wizard[self.lastStep]["text"] = str(attrs.get('value'))
45 elif (name == "listentry"):
46 self.wizard[self.lastStep]["list"].append(str(attrs.get('caption')))
47 elif (name == "config"):
48 exec "from Screens." + str(attrs.get('module')) + " import *"
49 self.wizard[self.lastStep]["config"]["screen"] = eval(str(attrs.get('screen')))
50 if (attrs.has_key('args')):
52 self.wizard[self.lastStep]["config"]["args"] = str(attrs.get('args'))
53 def endElement(self, name):
56 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"].strip()
58 def characters(self, ch):
59 if self.currContent == "code":
60 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"] + ch
62 def __init__(self, session):
63 self.skin = WelcomeWizard.skin
65 Screen.__init__(self, session)
66 HelpableScreen.__init__(self)
69 parser = make_parser()
70 print "Reading startwizard.xml"
71 wizardHandler = self.parseWizard(self.wizard)
72 parser.setContentHandler(wizardHandler)
73 parser.parse('/usr/share/enigma2/startwizard.xml')
75 self.numSteps = len(self.wizard)
78 self["text"] = Label()
79 self["rc"] = MovingPixmap()
80 self["arrowdown"] = MovingPixmap()
81 self["arrowup"] = MovingPixmap()
83 self["config"] = ConfigList([])
85 self["step"] = Label()
87 self["stepslider"] = Slider(1, self.numSteps)
90 self["list"] = MenuList(self.list)
94 self["actions"] = HelpableActionMap(self, "OkCancelActions",
96 "ok": (self.ok, _("Close this Screen...")),
99 def updateValues(self):
100 self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
101 self["stepslider"].setValue(self.currStep)
103 self["text"].setText(self.wizard[self.currStep]["text"])
106 if (len(self.wizard[self.currStep]["list"]) > 0):
107 for x in self.wizard[self.currStep]["list"]:
108 self.list.append((x, None))
109 self["list"].l.setList(self.list)
111 if (self.wizard[self.currStep]["config"]["screen"] != None):
112 print self.wizard[self.currStep]["config"]["screen"]
113 if self.wizard[self.currStep]["config"]["args"] == None:
114 self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"])
116 self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"]["screen"], eval(self.wizard[self.currStep]["config"]["args"]))
118 self["config"].l.setList(self.configInstance["config"].list)
120 self["config"].l.setList([])
122 if self.wizard[self.currStep]["code"] != "":
123 print self.wizard[self.currStep]["code"]
124 exec(self.wizard[self.currStep]["code"])
127 if (self.currStep == self.numSteps): # wizard finished
128 config.misc.firstrun.value = 0;
129 config.misc.firstrun.save()
135 def listActiveWizards():
138 if config.misc.firstrun.value:
139 wizards.append(WelcomeWizard)