import sys
from PyQt4 import QtGui
class Program(QtGui.QWidget):
def __init__(self):
super(Program, self).__init__()
self.initUI()
def initUI(self):
self.setFixedSize(235,100)
c = QtGui.QLineEdit(self)
c.setGeometry(150, 35, 25, 25)
btn = QtGui.QPushButton('Result', self)
btn.setGeometry(92.5, 75, 50, 25)
btn.clicked.connect(self.count)
def count(self):
self.c.setText('dadada')
app = QtGui.QApplication(sys.argv)
program = Program()
program.show()
sys.exit(app.exec_())
После нажатия, в консоле появляется надпись:
Traceback (most recent call last):
File "so.py", line 28, in count
self.c.setText('dadada')
AttributeError: 'Program' object has no attribute 'c'