X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/cf81c9acef45dc09976065bb4e7ad9b4818c5aa6..77a115baa70d23d342a1b54aa5cedd57bc5d6282:/lib/python/Screens/MessageBox.py diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py index bde31e83..632c9bc5 100644 --- a/lib/python/Screens/MessageBox.py +++ b/lib/python/Screens/MessageBox.py @@ -1,21 +1,54 @@ 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["ErrorPixmap"] = Pixmap() + self["QuestionPixmap"] = Pixmap() + + self.list = [] + if type != self.TYPE_ERROR: + self.onShown.append(self["ErrorPixmap"].hideWidget) + elif type != self.TYPE_YESNO: + self.onShown.append(self["QuestionPixmap"].hideWidget) + + if type == self.TYPE_YESNO: + self.list = [ (_("yes"), 0), (_("no"), 1) ] - self["actions"] = ActionMap(["OkCancelActions"], + + self["list"] = MenuList(self.list) + + self["actions"] = ActionMap(["MsgBoxActions"], { "cancel": self.cancel, - "ok": self.ok + "ok": self.ok, + "alwaysOK": self.alwaysOK }) + def cancel(self): self.close(False) def ok(self): - self.close(True) + if self.type == self.TYPE_YESNO: + self.close(self["list"].getCurrent()[1] == 0) + else: + self.close(True) + + def alwaysOK(self): + self.close(True) \ No newline at end of file