Skip to content

Instantly share code, notes, and snippets.

@DataSolveProblems
Last active August 27, 2020 09:22
Show Gist options
  • Save DataSolveProblems/aa75552154d553ed83d06ef48616a428 to your computer and use it in GitHub Desktop.
Save DataSolveProblems/aa75552154d553ed83d06ef48616a428 to your computer and use it in GitHub Desktop.
import sys
from PyQt5.QtWidgets import (QApplication, QWidget)
from PyQt5.Qt import Qt
class MainWindow(QWidget):
def __init__(self):
super().__init__()
def keyPressEvent(self, event):
if event.key() == Qt.Key_Space:
self.test_method()
def test_method(self):
print('Space key pressed')
if __name__ == '__main__':
app = QApplication(sys.argv)
demo = MainWindow()
demo.show()
sys.exit(app.exec_())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment