Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pyside:QLineEdit接受多个输入_Python_Python 3.x_Pyside_Qlineedit - Fatal编程技术网

Python Pyside:QLineEdit接受多个输入

Python Pyside:QLineEdit接受多个输入,python,python-3.x,pyside,qlineedit,Python,Python 3.x,Pyside,Qlineedit,我在Qt设计器中开发了一个GUI,用户可以在QLineEdit中输入两个值,当用户点击enter时,它会执行一些数学计算 问题是一旦输入了值并在输出后按下enter键,我就无法将输入输入到QLineEdit,但每次都必须重新启动GUI。这是我的密码: def entervalues(self): if self.RotationEdit.text() != "" and self.TiltEdit.text() != "": self.Rotati

我在Qt设计器中开发了一个GUI,用户可以在
QLineEdit
中输入两个值,当用户点击enter时,它会执行一些数学计算

问题是一旦输入了值并在输出后按下enter键,我就无法将输入输入到
QLineEdit
,但每次都必须重新启动GUI。这是我的密码:

    def entervalues(self):
        if self.RotationEdit.text() != "" and self.TiltEdit.text() != "":
            self.RotationEdit = str(self.RotationEdit.text())
            self.TiltEdit = str(self.TiltEdit.text())
            self.pass_arguments.emit("self.RotationEdit","self.TiltEdit")
        else:
            QMessageBox.information(self, "Error","No Values Entered")
如果我尝试输入值并按enter键,则会显示属性错误

    line 100, in entervalues
    if self.RotationEdit.text() != "" and self.TiltEdit.text() != "":
    AttributeError: 'str' object has no attribute 'text'

问题出现在代码中,您正在更改对象
self.RotationEdit

self.RotationEdit = str(self.RotationEdit.text())
当您最初声明这是一个QLineEdit时,但随后您分配了一个字符串。当您重新使用它时,它仍然是字符串,因此未定义
text()
函数。我建议创建一个包含这些值的新变量​​您将在另一个函数中使用的

def entervalues(self):
    if self.RotationEdit.text() != "" and self.TiltEdit.text() != "":
        self.pass_arguments.emit(self.RotationEdit.text(),self.TiltEdit.text())
    else:
        QMessageBox.information(self, "Error","No Values Entered")

这些值self.RotationEdit和self.TiltEdit被传递到另一个函数中,该函数在按下enter键编辑QLineEdit
self.pass\u arguments.emit(self.RotationEdit.text(),self.TiltEdit.text())时执行数学计算。