0

I will try to lay this out as best I can. I am writing a GUI with PyQt4 using Python 3.4.3.

The code I am writing stores information in a list and then pulls information from said list in order to complete tasks based on comparative logic between set positions in the list. Though it does not seem to like sending the text of a lineEdit in to a list and returns the error found at the bottom. Thanks for any assistance given. I'm sure it's something simple that I am overlooking.

The following is my code:

class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        self.lineedit = QtGui.QLineEdit()
        self.lineedit.setObjectName(_fromUtf8("lineedit"))
        self.gridLayout_3.addWidget(self.lineedit, 30, 3, 1, 1)
        self.button = QtGui.QPushButton(self.tab_6)
        self.button.setObjectName(_fromUtf8("button"))
        self.gridLayout_6.addWidget(button, 0, 3, 1, 1)
        self.button.clicked.connect(Ui_MainWindow.call)

    list = [1, 2, 3]

    def call(self)
        Ui_MainWindow.list[0] = self.lineedit.text()

This is the error message I have been getting from the above:

Traceback (most recent call last):
File "filename", line 11, in call
Ui_MainWindow.list[0] = self.lineedit.text()
AttributeError: 'bool' object has no attribute 'lineedit'

My question would be, why does this code error out rather than sending the .text() of lineedit to my list?

  • it seems you made `self = True/False ` in some place so now you have `True.lineedit.text()`. How do you execute `call()` function ? BTW: is it function inside class `Ui_MainWindow` ? – furas Oct 17 '16 at 04:31
  • I've added the button portion of the code to the above. I'm searching for that rogue self somewhere in the code. – Kaijinmaru Oct 17 '16 at 12:25
  • why do you use `Ui_MainWindow.call` instead of `self.call` in `connect()` ? – furas Oct 17 '16 at 12:34
  • That is a very good question actually. And once referenced to self.call instead of Ui_MainWindow.call it works. Now for the mandatory "How in the world did I think that would work?" – Kaijinmaru Oct 17 '16 at 13:00

0 Answers0