美文网首页
2019-03-05 如何接收键值

2019-03-05 如何接收键值

作者: gongdiwudu | 来源:发表于2019-03-05 21:32 被阅读0次

# escape.py

# !/usr/bin/python3

# -*- coding: utf-8 -*-

"""

ZetCode PyQt5 tutorial

In this example, we reimplement an

event handler.

Author: Jan Bodnar

Website: zetcode.com

Last edited: August 2017

"""

import sys

from PyQt5.QtCoreimport Qt

from PyQt5.QtWidgetsimport QWidget, QApplication

class Example(QWidget):

def __init__(self):

super().__init__()

self.initUI()

def initUI(self):

self.setGeometry(300,300,250,150)

self.setWindowTitle('Event handler')

self.show()

def keyPressEvent(self, e):

if e.key() == Qt.Key_Escape:

self.close()

if __name__ =='__main__':

app = QApplication(sys.argv)

ex = Example()

sys.exit(app.exec_())

相关文章

网友评论

      本文标题:2019-03-05 如何接收键值

      本文链接:https://www.haomeiwen.com/subject/uosauqtx.html