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
11 from Screens.ScanSetup import ScanSimple
13 from xml.sax import make_parser
14 from xml.sax.handler import ContentHandler
16 config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1);
18 class WelcomeWizard(Screen, HelpableScreen):
21 <screen position="0,0" size="720,560" title="Welcome..." flags="wfNoBorder" >
22 <widget name="text" position="50,100" size="440,200" font="Arial;23" />
23 <widget name="list" position="50,300" size="440,200" />
24 <widget name="config" position="50,300" zPosition="100" size="440,200" />
25 <widget name="step" position="50,50" size="440,25" font="Arial;23" />
26 <widget name="stepslider" position="50,500" zPosition="1" size="440,20" backgroundColor="dark" />
27 <widget name="rc" pixmap="/usr/share/enigma2/rc.png" position="500,600" size="154,475" transparent="1" alphatest="on"/>
28 <widget name="arrowdown" pixmap="/usr/share/enigma2/arrowdown.png" position="0,0" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
29 <widget name="arrowup" pixmap="/usr/share/enigma2/arrowup.png" position="-100,-100" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
32 class parseWizard(ContentHandler):
33 def __init__(self, wizard):
34 self.isPointsElement, self.isReboundsElement = 0, 0
38 def startElement(self, name, attrs):
39 self.currContent = name
41 self.lastStep = int(attrs.get('number'))
42 self.wizard[self.lastStep] = {"text": "", "list": [], "config": 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"] = eval(str(attrs.get('screen')))
51 def endElement(self, name):
54 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"].strip()
56 def characters(self, ch):
57 if self.currContent == "code":
58 self.wizard[self.lastStep]["code"] = self.wizard[self.lastStep]["code"] + ch
60 def __init__(self, session):
61 self.skin = WelcomeWizard.skin
63 Screen.__init__(self, session)
64 HelpableScreen.__init__(self)
68 parser = make_parser()
69 print "Reading startwizard.xml"
70 wizardHandler = self.parseWizard(self.wizard)
71 parser.setContentHandler(wizardHandler)
72 parser.parse('/usr/share/enigma2/startwizard.xml')
79 self["text"] = Label()
80 self["rc"] = MovingPixmap()
81 self["arrowdown"] = MovingPixmap()
82 self["arrowdown"].moveTo(557, 232, 10)
83 self["arrowup"] = MovingPixmap()
84 self["rc"].moveTo(500, 50, 10)
85 self["config"] = ConfigList([])
87 self.onShown.append(self["arrowdown"].startMoving)
88 self.onShown.append(self["rc"].startMoving)
90 self["step"] = Label()
92 self["stepslider"] = Slider(1, self.numSteps)
94 #self.scanSetupDialog = self.session.instantiateDialog(ScanSimple)
97 #list.append(("Use wizard to set up basic features", None))
98 #list.append(("Exit wizard", None))
99 self["list"] = MenuList(self.list)
103 self["actions"] = HelpableActionMap(self, "OkCancelActions",
105 "ok": (self.ok, _("Close this Screen...")),
108 def updateValues(self):
109 self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
110 self["stepslider"].setValue(self.currStep)
112 self["text"].setText(self.wizard[self.currStep]["text"])
115 if (len(self.wizard[self.currStep]["list"]) > 0):
116 for x in self.wizard[self.currStep]["list"]:
117 self.list.append((x, None))
118 self["list"].l.setList(self.list)
120 if (self.wizard[self.currStep]["config"] != None):
121 self.configInstance = self.session.instantiateDialog(self.wizard[self.currStep]["config"])
122 self["config"].l.setList(self.configInstance["config"].list)
124 self["config"].l.setList([])
126 if self.wizard[self.currStep]["code"] != "":
127 print self.wizard[self.currStep]["code"]
128 exec(self.wizard[self.currStep]["code"])
131 if (self.currStep == self.numSteps): # wizard finished
132 config.misc.firstrun.value = 0;
133 config.misc.firstrun.save()
139 def listActiveWizards():
142 if config.misc.firstrun.value:
143 wizards.append(WelcomeWizard)