X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/6fc007ad54d256e0b6548f22707416d501de595b..94f8049fca5c1522aef72334ab4f4697600618c0:/lib/python/Screens/MessageBox.py diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py index 87da7f9c..51dd2fb4 100644 --- a/lib/python/Screens/MessageBox.py +++ b/lib/python/Screens/MessageBox.py @@ -2,21 +2,45 @@ 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): - def __init__(self, session, text): + 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["key_green"] = Button("OK") - self["key_red"] = Button("Exit") + 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 + "ok": self.ok, + "alwaysOK": self.alwaysOK }) @@ -24,4 +48,10 @@ class MessageBox(Screen): 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)