fix linked tuners
[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 from Components.MenuList import MenuList
10
11 config.misc.firstrun = configElementBoolean("config.misc.firstrun", 1);
12
13 class WelcomeWizard(Screen, HelpableScreen):
14
15         skin = """
16                 <screen position="0,0" size="720,560" title="Welcome..." flags="wfNoBorder" >
17                         <widget name="text" position="50,100" size="440,200" font="Arial;23" />
18                         <widget name="list" position="50,300" size="440,200" />
19                         <widget name="step" position="50,50" size="440,25" font="Arial;23" />
20                         <widget name="stepslider" position="50,500" zPosition="1" size="440,20" backgroundColor="dark" />
21                         <widget name="rc" pixmap="/usr/share/enigma2/rc.png" position="500,50" size="154,475" transparent="1" alphatest="on"/>
22                         <widget name="arrowdown" pixmap="/usr/share/enigma2/arrowdown.png" position="0,0" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
23                         <widget name="arrowup" pixmap="/usr/share/enigma2/arrowup.png" position="-100,-100" zPosition="1" size="37,70" transparent="1" alphatest="on"/>
24                 </screen>"""
25                 
26         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."), 
27                         _("You can use the Up and Down buttons on your remote control to select your choice.\n\nWhat do you want to do?"),
28                         _("Blub")]
29                         
30         listEntries = [[],
31                                     ["Use wizard to set up basic features", "Exit wizard"],
32                                         []]
33
34         def __init__(self, session):
35                 self.skin = WelcomeWizard.skin
36                 self.numSteps = 3
37                 self.currStep = 1
38
39                 Screen.__init__(self, session)
40                 HelpableScreen.__init__(self)
41
42
43                 self["text"] = Label()
44                 self["rc"] = Pixmap()
45                 self["arrowdown"] = MovingPixmap()
46                 self["arrowdown"].moveTo(557, 232, 100)
47                 self["arrowup"] = MovingPixmap()
48                 
49                 self.onShown.append(self["arrowdown"].startMoving)
50
51                 self["step"] = Label()
52                                 
53                 self["stepslider"] = Slider(1, self.numSteps)
54                 
55                 self.list = []
56                 #list.append(("Use wizard to set up basic features", None))
57                 #list.append(("Exit wizard", None))
58                 self["list"] = MenuList(self.list)
59
60                 self.updateValues()
61                 
62                 self["actions"] = HelpableActionMap(self, "OkCancelActions",
63                         {
64                                 "ok": (self.ok, _("Close this Screen...")),
65                         })
66
67         def updateValues(self):
68                 self["text"].setText(self.text[self.currStep - 1])
69                 self["step"].setText(_("Step ") + str(self.currStep) + "/" + str(self.numSteps))
70                 self["stepslider"].setValue(self.currStep)
71                 self.list = []
72                 
73                 if (len(self.listEntries[self.currStep - 1]) > 0):
74                         for x in self.listEntries[self.currStep - 1]:
75                                 self.list.append((x, None))
76                 self["list"].l.setList(self.list)
77                 
78         def ok(self):
79                 if (self.currStep == self.numSteps): # wizard finished
80                         config.misc.firstrun.value = 0;
81                         config.misc.firstrun.save()
82                         self.session.close()
83                 else:
84                         self.currStep += 1
85                         self.updateValues()
86                         
87                         if (self.currStep == 2):
88                                 self["arrowdown"].moveTo(557, 200, 100)
89                                 self["arrowup"].moveTo(557, 355, 100)
90                                 self["arrowdown"].startMoving()
91                                 self["arrowup"].startMoving()
92                                 
93
94 def listActiveWizards():
95         wizards = [ ]
96
97         if config.misc.firstrun.value:
98                 wizards.append(WelcomeWizard)
99         
100         return wizards