PyQt4事件绑定
程序员文章站
2022-05-11 08:12:03
...
# -*- coding: utf-8 -*-
import sys
from PyQt4 import QtGui, QtCore
from PyQt4.QtCore import pyqtSignature
from frm_revocation import Ui_Form
#Ui_Form是我用qt designer画的
class FrmRevocationEx(Ui_Form):
__app = QtGui.QApplication(sys.argv)
_w = QtGui.QWidget()
def __init__(self):
self.setupUi(self._w)
#第一种方式
#QtCore.QObject.connect(self.btn_process, QtCore.SIGNAL('clicked()'), self.on_btn_process_clicked)
#第二种方式
self.btn_process.clicked.connect(self.on_btn_process_clicked)
pass
#第三种方式, 这种方式, 需要继承QWidget
@pyqtSignature("")
def on_btn_process_clicked(self):
print 'on_btn_process_clicked'
pass
if __name__ == '__main__':
app = QtGui.QApplication(sys.argv)
s = FrmRevocationEx()
s._w.show()
sys.exit(app.exec_())