- add fake "main menu"
[enigma2.git] / screens.py
1 from components import *
2 import sys
3
4 # some screens
5 def doGlobal(screen):
6         screen["clock"] = Clock()
7
8 class Screen(dict, HTMLSkin, GUISkin):
9         """ bla """
10         
11         # never call this directly - it will be called from the session!
12         def doClose(self):
13                 GUISkin.close(self)
14         
15         def close(self, retval=None):
16                 self.session.close()
17         
18 # a test dialog
19 class testDialog(Screen):
20         def testDialogClick(self):
21                 selection = self["menu"].getCurrent()
22                 selection[1]()
23         
24         def goMain(self):
25                 self.session.open(screens["mainMenu"]())
26                 
27         def goEmu(self):
28 #               self.close(1)
29                 self["title"].setText("EMUs ARE ILLEGAL AND NOT SUPPORTED!")
30         
31         def goTimeshift(self):
32 #               self.close(2)
33                 self["title"].setText("JUST PRESS THE YELLOW BUTTON!")
34         
35         def goHDTV(self):
36 #               self.close(3)
37                 self["title"].setText("HDTV GREEN FLASHES: ENABLED")
38         
39         def goClock(self):
40                 self.session.open(screens["clockDisplay"](Clock()))
41
42         def __init__(self):
43                 GUISkin.__init__(self)
44                 b = Button("ok")
45                 b.onClick = [ self.testDialogClick ]
46                 self["okbutton"] = b
47                 self["title"] = Header("Test Dialog - press ok to leave!")
48                 self["menu"] = MenuList(
49                         [
50                                 ("MAIN MENU", self.goMain), 
51                                 ("EMU SETUP", self.goEmu),
52                                 ("TIMESHIFT SETUP", self.goTimeshift),
53                                 ("HDTV PIP CONFIG", self.goHDTV),
54                                 ("wie spaet ists?!", self.goClock)
55                         ])
56
57 class mainMenu(Screen):
58         def __init__(self):
59                 GUISkin.__init__(self)
60                 
61                 self["title"] = Header("this is the\nMAIN MENU !!!");
62                 self["okbutton"] = Button("ok")
63                 self["okbutton"].onClick = [ self.close ]
64
65         
66 # a clock display dialog
67 class clockDisplay(Screen):
68         def okbutton(self):
69                 self.session.close()
70         
71         def __init__(self, clock):
72                 GUISkin.__init__(self)
73                 self["theClock"] = clock
74                 b = Button("bye")
75                 b.onClick = [ self.okbutton ]
76                 self["okbutton"] = b
77                 self["title"] = Header("clock dialog: here you see the current uhrzeit!")
78
79 # defined screens (evtl. kann man sich das sparen, ich seh den sinn gerade nicht mehr)
80 screens = {
81         "global": doGlobal,
82         "testDialog": testDialog,
83         "clockDisplay": clockDisplay ,
84         "mainMenu": mainMenu }
85