X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/fb412ff32c7938649c72d55eed3f5c8ccb5e0a99..fcea714ed304234bdb7e05e40c3e3d7109fbd1f1:/lib/python/Screens/MessageBox.py diff --git a/lib/python/Screens/MessageBox.py b/lib/python/Screens/MessageBox.py index ed3bb4f4..b16b8730 100644 --- a/lib/python/Screens/MessageBox.py +++ b/lib/python/Screens/MessageBox.py @@ -12,12 +12,15 @@ class MessageBox(Screen): TYPE_WARNING = 2 TYPE_ERROR = 3 - def __init__(self, session, text, type = TYPE_YESNO, timeout = -1): + def __init__(self, session, text, type = TYPE_YESNO, timeout = -1, close_on_any_key = False): self.type = type Screen.__init__(self, session) self["text"] = Label(text) + self.text = text + self.close_on_any_key = close_on_any_key + self["ErrorPixmap"] = Pixmap() self["QuestionPixmap"] = Pixmap() self["InfoPixmap"] = Pixmap() @@ -25,7 +28,7 @@ class MessageBox(Screen): if timeout > 0: self.timer = eTimer() self.timer.timeout.get().append(self.timerTick) - self.timer.start(1000) + self.onExecBegin.append(self.startTimer) self.origTitle = None self.onShown.append(self.timerTick) self.timerRunning = True @@ -59,18 +62,21 @@ class MessageBox(Screen): "leftRepeated": self.left, "rightRepeated": self.right }, -1) - - + + def startTimer(self): + self.timer.start(1000) + def timerTick(self): - self.timeout -= 1 - if self.origTitle is None: - self.origTitle = self.instance.getTitle() - self.setTitle(self.origTitle + " (" + _("Timeout: ") + str(self.timeout) + ")") - if self.timeout == 0: - self.timer.stop() - self.timerRunning = False - self.timeoutCallback() - + if self.execing: + self.timeout -= 1 + if self.origTitle is None: + self.origTitle = self.instance.getTitle() + self.setTitle(self.origTitle + " (" + str(self.timeout) + ")") + if self.timeout == 0: + self.timer.stop() + self.timerRunning = False + self.timeoutCallback() + def timeoutCallback(self): print "Timeout!" self.ok() @@ -96,14 +102,18 @@ class MessageBox(Screen): def left(self): self.move(self["list"].instance.pageUp) - - def right(self): self.move(self["list"].instance.pageDown) def move(self, direction): + if self.close_on_any_key: + self.close(True) + self["list"].instance.moveSelection(direction) if self.timerRunning: self.timer.stop() self.setTitle(self.origTitle) - self.timerRunning = False \ No newline at end of file + self.timerRunning = False + + def __repr__(self): + return str(type(self)) + "(" + self.text + ")"