[英]Error:Can't assign to function call Python/PyQt
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. 我试图将文本输入(用户名和密码)分配给新变量(IPassword和IUsername),以用于其他定义。 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
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. 希望对您有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.