632c9bc5dc9157e9519b9661701eeb6c07d9e8f9
[enigma2.git] / lib / python / Screens / MessageBox.py
1 from Screen import Screen
2 from Components.ActionMap import ActionMap
3 from Components.Label import Label
4 from Components.Button import Button
5 from Components.Pixmap import Pixmap
6 from Components.MenuList import MenuList
7 from enigma import eSize, ePoint
8
9 class MessageBox(Screen):
10         TYPE_YESNO = 0
11         TYPE_INFO = 1
12         TYPE_WARNING = 2
13         TYPE_ERROR = 3
14         
15         def __init__(self, session, text, type = TYPE_YESNO):
16                 self.type = type
17                 Screen.__init__(self, session)
18                 
19                 self["text"] = Label(text)
20                 
21                 self["ErrorPixmap"] = Pixmap()
22                 self["QuestionPixmap"] = Pixmap()
23                 
24                 self.list = []
25                 if type != self.TYPE_ERROR:
26                         self.onShown.append(self["ErrorPixmap"].hideWidget)
27                 elif type != self.TYPE_YESNO:
28                         self.onShown.append(self["QuestionPixmap"].hideWidget)
29
30                 if type == self.TYPE_YESNO:
31                         self.list = [ (_("yes"), 0), (_("no"), 1) ]
32
33
34                 self["list"] = MenuList(self.list)
35                 
36                 self["actions"] = ActionMap(["MsgBoxActions"], 
37                         {
38                                 "cancel": self.cancel,
39                                 "ok": self.ok,
40                                 "alwaysOK": self.alwaysOK
41                         })
42                         
43         
44         def cancel(self):
45                 self.close(False)
46         
47         def ok(self):
48                 if self.type == self.TYPE_YESNO:
49                         self.close(self["list"].getCurrent()[1] == 0)
50                 else:
51                         self.close(True)
52
53         def alwaysOK(self):
54                 self.close(True)