PYQT 自定义SLOT函数报错
#!/usr/bin/python
#-*-coding:utf-8-*-
#mymoney.py
from PyQt4.QtGui import *
from PyQt4.QtCore import *
import sys
class loginW(QWidget):
def __init__(self, parent=None):
QWidget.__init__(self, parent)
self.resize(250,250)
self.setWindowTitle('login')
userLabel=QLabel('username:')
pwdLabel=QLabel('password:')
userle=QLineEdit()
pwdle=QLineEdit()
okButton=QPushButton('OK')
cnlButton=QPushButton('Cancel')
grid = QGridLayout()
grid.addWidget(userLabel,0,1)
grid.addWidget(userle,0,2)
grid.addWidget(pwdLabel,1,1)
grid.addWidget(pwdle,1,2)
grid.addWidget(okButton, 2, 1)
grid.addWidget(cnlButton, 2, 2)
self.setLayout(grid)
#okButton.clicked.connect(self.okcheck)
self.connect(okButton,SIGNAL("clicked()"),self,self.okcheck)
self.connect(cnlButton,SIGNAL("clicked()"),self,SLOT("close()"))
def okcheck(self):
print 'a'
#class MainWindow(QMainWindow):
"""docstring for MainWindow"""
def __init__(self):
QMainWindow.__init__(self)
self.resize(250, 150)
self.setWindowTitle('mymoney')
self.statusBar().showMessage('Ready')
app=QApplication(sys.argv)
#main=MainWindow()
main=loginW()
main.show()
app.exec_()