Question

I am trying to assign the text input (Username and password) to a new variable (IPassword and IUsername) to be used in other def's. I cant get it to work, When running the code i get the following error 'Error: Can't assign to function call'. The code is below:

class LoginWidget(QtGui.QWidget):
    success = QtCore.pyqtSignal()
    def __init__(self, parent=None):
        super(LoginWidget, self).__init__(parent)
        self.Username = QtGui.QLineEdit(self)  
        self.Password = QtGui.QLineEdit(self)
        self.Password.text() = IPassword
        self.Username.text() = IUsername
        self.buttonLogin = QtGui.QPushButton('Login', self)
        self.buttonLogin.clicked.connect(self.handleLogin)
    def handleLogin(self):
        global IPassword
        global IUsername
Was it helpful?

Solution

You can't assign values to function calls. So, you can't do that:

self.Password.text() = IPassword
self.Username.text() = IUsername

The correct way to do it, is:

self.Password.setText(IPassword)
self.Username.setText(IUsername)

I hope it helps.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top