use steps in startwizard
[vuplus_dvbapp] / lib / python / Screens / Wizard.py
1 from Screen import Screen
2
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 Pixmap
9
10 config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1);
11
12 class WelcomeWizard(Screen, HelpableScreen):
13
14         skin = """
15                 <screen position="0,0" size="720,560" title="Welcome..." flags="wfNoBorder">
16                         <widget name="text" position="50,100" size="440,300" font="Arial;23" />
17                         <widget name="step" position="50,50" size="440,25" font="Arial;23" />
18                         <widget name="stepslider" position="50,500" zPosition="1" size="440,20" backgroundColor="dark" />
19                         <widget name="rc" pixmap="/usr/share/enigma2/rc.png" position="500,50" size="154,475" alphatest="on" />
20                         <widget name="arrowdown" pixmap="/usr/share/enigma2/arrowdown.png" position="557,232" zPosition="1" size="37,70" alphatest="on" />
21                 </screen>"""
22                 
23         text = [_("Hello User.\n\nThis start-wizard will guide you through the basic setup of your Dreambox."), 
24                         _("Bla"),
25                         _("Blub")]
26
27         def __init__(self, session):
28                 self.skin = WelcomeWizard.skin
29                 self.numSteps = 3
30                 self.currStep = 1
31
32                 Screen.__init__(self, session)
33                 HelpableScreen.__init__(self)
34
35
36                 self["text"] = Label()
37                 self["rc"] = Pixmap()
38                 self["arrowdown"] = Pixmap()
39
40                 self["step"] = Label()
41                                 
42                 self["stepslider"] = Slider(1, self.numSteps)
43
44                 self.updateValues()
45                 
46                 self["actions"] = HelpableActionMap(self, "OkCancelActions",
47                         {
48                                 "ok": (self.ok, _("Close this Screen...")),
49                         })
50
51         def updateValues(self):
52                 self["text"].setText(self.text[self.currStep - 1])
53                 self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
54                 self["stepslider"].setValue(self.currStep)
55                 
56         def ok(self):
57                 if (self.currStep == self.numSteps): # wizard finished
58                         config.misc.firstrun.value = 0;
59                         config.misc.firstrun.save()
60                         self.session.close()
61                 else:
62                         self.currStep += 1
63                         self.updateValues()
64
65 def listActiveWizards():
66         wizards = [ ]
67
68         if config.misc.firstrun.value:
69                 wizards.append(WelcomeWizard)
70         
71         return wizards