99ed19fbe51cf31762709f9a3a75b0bf01aef0c4
[enigma2.git] / 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 *
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" transparent="1" alphatest="on"/>
20                         <widget name="arrowdown" pixmap="/usr/share/enigma2/arrowdown.png" position="0,0" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
21                         <widget name="arrowup" pixmap="/usr/share/enigma2/arrowup.png" position="-100,-100" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
22                 </screen>"""
23                 
24         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."), 
25                         _("You can use the Up and Down buttons on your remote control to select your choice.\n\nWhat do you want to do?"),
26                         _("Blub")]
27
28         def __init__(self, session):
29                 self.skin = WelcomeWizard.skin
30                 self.numSteps = 3
31                 self.currStep = 1
32
33                 Screen.__init__(self, session)
34                 HelpableScreen.__init__(self)
35
36
37                 self["text"] = Label()
38                 self["rc"] = Pixmap()
39                 self["arrowdown"] = MovingPixmap()
40                 self["arrowdown"].moveTo(557, 232, 100)
41                 self["arrowup"] = MovingPixmap()
42
43                 
44                 self.onShown.append(self["arrowdown"].startMoving)
45
46                 self["step"] = Label()
47                                 
48                 self["stepslider"] = Slider(1, self.numSteps)
49
50                 self.updateValues()
51                 
52                 self["actions"] = HelpableActionMap(self, "OkCancelActions",
53                         {
54                                 "ok": (self.ok, _("Close this Screen...")),
55                         })
56
57         def updateValues(self):
58                 self["text"].setText(self.text[self.currStep - 1])
59                 self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
60                 self["stepslider"].setValue(self.currStep)
61                 
62         def ok(self):
63                 if (self.currStep == self.numSteps): # wizard finished
64                         config.misc.firstrun.value = 0;
65                         config.misc.firstrun.save()
66                         self.session.close()
67                 else:
68                         self.currStep += 1
69                         self.updateValues()
70                         
71                         if (self.currStep == 2):
72                                 self["arrowdown"].moveTo(557, 200, 100)
73                                 self["arrowup"].moveTo(557, 355, 100)
74                                 self["arrowdown"].startMoving()
75                                 self["arrowup"].startMoving()
76                                 
77
78 def listActiveWizards():
79         wizards = [ ]
80
81         if config.misc.firstrun.value:
82                 wizards.append(WelcomeWizard)
83         
84         return wizards