반응형

/*********************************************************************************************************

-- Title : [PyQt4] Function Key 인식 구현
-- Reference : http://stackoverflow.com/

-- Key word : python pyqt pyqt4 qt qt4 파이썬 F5 functionkey function key
*********************************************************************************************************/




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# -*- coding: utf-8 -*-
 
import sys, string
from PyQt4 import QtGui, QtCore
 
class Window(QtGui.QMainWindow):
    def __init__(self):
        super(Window, self).__init__()
 
        self.setGeometry(300,300,250,150)
        self.setWindowTitle('Event handler')
 
        tLabel = QtGui.QLabel(self)
        tLabel.move(2020)
        tLabel.resize(25040)
        tLabel.setText("Try to click <F5> button,\n then this windows will be closed.")
 
    def keyPressEvent(self, e):
 
        if e.key() == QtCore.Qt.Key_F5:
            self.close()
 
if __name__ == "__main__":
    app = QtGui.QApplication(sys.argv)
    gui = Window()
    gui.show()
    sys.exit(app.exec_())
 
 

cs


반응형

+ Recent posts