def keyPressEvent(self,e): '''Close the window if escape is pressed, otherwise do as inherited.''' if e.key() == Qt.Key_Escape: self.close() else: QtGui.QMainWindow.keyPressEvent(self,e)