import sys
from PyQt4 import QtGui, QtCore
class SigSlot(QtGui.QWidget):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setWindowTitle('signal & slot')
but=QtGui.QPushButton('КНОПКА',self)
but.resize(200, 100)
but.clicked.connect(self.function)
def Scr(self):
print('test')
self.resize(250, 150)
app = QtGui.QApplication(sys.argv)
qb = SigSlot()
qb.show()
sys.exit(app.exec_())
Ошибка:
Traceback (most recent call last):
File "111.py", line 16, in
qb = SigSlot()
File "111.py", line 11, in __init__
but.clicked.connect(self.function)
AttributeError: 'SigSlot' object has no attribute 'function'