From 7d79d47cc3433b96bbbcb68c9e9018855b14e5db Mon Sep 17 00:00:00 2001 From: Sebastian Lohff Date: Thu, 7 Nov 2013 01:19:50 +0100 Subject: [PATCH] Code for key-handling --- game.py | 5 +++++ windows.py | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/game.py b/game.py index c1c181c..ef08083 100644 --- a/game.py +++ b/game.py @@ -54,6 +54,11 @@ class SeopardyGame(QtGui.QWidget): self.setLayout(layout) + def keyPressEvent(self, e): + print("Mainwindow", e) + if e.key() == QtCore.Qt.Key_Escape: + self.close() + def tfunc(self, section, number): print("question window", section, number) diff --git a/windows.py b/windows.py index deedbf5..d7b67e9 100644 --- a/windows.py +++ b/windows.py @@ -48,3 +48,7 @@ class QuestionWindow(QtGui.QDialog): self.setLayout(self.layout) + def keyPressEvent(self, e): + print("question", e, e.key()) + if e.key() == QtCore.Qt.Key_Escape: + self.close()