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, eTimer
9 class MessageBox(Screen):
15 def __init__(self, session, text, type = TYPE_YESNO, timeout = -1):
17 Screen.__init__(self, session)
19 self["text"] = Label(text)
21 self["ErrorPixmap"] = Pixmap()
22 self["QuestionPixmap"] = Pixmap()
23 self["InfoPixmap"] = Pixmap()
24 self.timerRunning = False
27 self.timer.timeout.get().append(self.timerTick)
28 self.timer.start(1000)
30 self.onShown.append(self.timerTick)
31 self.timerRunning = True
32 self.timeout = timeout
35 if type != self.TYPE_ERROR:
36 self["ErrorPixmap"].hide()
37 if type != self.TYPE_YESNO:
38 self["QuestionPixmap"].hide()
39 if type != self.TYPE_INFO:
40 self["InfoPixmap"].hide()
42 if type == self.TYPE_YESNO:
43 self.list = [ (_("yes"), 0), (_("no"), 1) ]
46 self["list"] = MenuList(self.list)
48 self["actions"] = ActionMap(["MsgBoxActions", "DirectionActions"],
50 "cancel": self.cancel,
52 "alwaysOK": self.alwaysOK,
57 "upRepeated": self.up,
58 "downRepeated": self.down,
59 "leftRepeated": self.left,
60 "rightRepeated": self.right
66 if self.origTitle is None:
67 self.origTitle = self.instance.getTitle()
68 self.setTitle(self.origTitle + " (" + _("Timeout: ") + str(self.timeout) + ")")
71 self.timerRunning = False
72 self.timeoutCallback()
74 def timeoutCallback(self):
82 if self.type == self.TYPE_YESNO:
83 self.close(self["list"].getCurrent()[1] == 0)
91 self.move(self["list"].instance.moveUp)
94 self.move(self["list"].instance.moveDown)
97 self.move(self["list"].instance.pageUp)
102 self.move(self["list"].instance.pageDown)
104 def move(self, direction):
105 self["list"].instance.moveSelection(direction)
106 if self.timerRunning:
108 self.setTitle(self.origTitle)
109 self.timerRunning = False