经过多次努力,我终于可以设计我的gui并将其转换为python脚本,唯一需要的就是绑定它。
我正在处理一个函数,该函数从用户获取两个字符串输入并将它们传递给函数,然后返回两个值,一个列表和一个变量。我正在使用QT设计器5.4.1,我尝试了很多次来实现我想要但从未工作过的东西。请注意,原始函数不在QT创建的类中。我的代码:
# Two lineEdit will take starting point and ending point and
# pushButton should call the function and pass start and end and show the value in lineEdit_4
self.lineEdit.setPlaceholderText(_translate("Form", "Starting Point", None))
self.lineEdit_2.setPlaceholderText(_translate("Form", "Ending Point", None))
self.lineEdit_4.setPlaceholderText(_translate("Form", None))
self.pushButton.setText(_translate("Form", "Find Shortest Path", None))
self.pushButton.clicked.connect(self.callshortest)
def callshortest(self,shortest,graph,start,end):
start = str(self.lineEdit.text())
end = str(self.lineEdit_2.text())
return shortest(graph,start,end)
x,y= callshortest(graph,start,end)
def show(self,x,y):
return self.lineEdit_4.show(x+y)
即使在QT创建的行中,这也会出现语法错误!
非常感谢任何帮助或guidanace ..