Last active
August 27, 2020 09:22
-
-
Save DataSolveProblems/aa75552154d553ed83d06ef48616a428 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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