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