From ff07c4700e19cd3197fd8bac1ab8346b18aaaf15 Mon Sep 17 00:00:00 2001 From: Jeremy Stanley Date: Wed, 22 Jul 2015 20:16:21 +0000 Subject: Use the q key to quit gracefully Relying on ctrl-C user interrupt to exit leaves the terminal in a dirty state, and potentially unusable. Add the ability to exit gracefully by pressing the q key. --- README.rst | 2 ++ presentty/console.py | 2 ++ presentty/presentty.py | 2 ++ 3 files changed, 6 insertions(+) diff --git a/README.rst b/README.rst index 1855710..1e4a37f 100644 --- a/README.rst +++ b/README.rst @@ -56,6 +56,8 @@ In either the presenter's console or the main presentty window, the left and right arrow keys or page-up and page-down navigate between slides. +To exit presentty gracefully, use the 'q' key. + Source ------ diff --git a/presentty/console.py b/presentty/console.py index d29b864..d10dc3e 100644 --- a/presentty/console.py +++ b/presentty/console.py @@ -172,6 +172,8 @@ class Screen(urwid.WidgetWrap): self.console.prev() elif key == 't': self.console.timerDialog() + elif key == 'q': + raise urwid.ExitMainLoop() else: return super(Screen, self).keypress(size, key) return None diff --git a/presentty/presentty.py b/presentty/presentty.py index 35e19c1..b7589bf 100644 --- a/presentty/presentty.py +++ b/presentty/presentty.py @@ -78,6 +78,8 @@ class Presenter(object): self.nextSlide() elif key in ('left', 'page up'): self.prevSlide() + elif key == 'q': + raise urwid.ExitMainLoop() def transitionTo(self, index, forward=True): self.pos = index -- cgit v1.2.3