【发布时间】:2017-05-08 14:05:31
【问题描述】:
我正在构建一个 GUI 应用程序,我一直在尝试调试代码并对其进行测试,但它一直向我抛出这个错误说。我在 MainWindow 类中添加了一个按钮功能,它是“self.AddtoCart.clicked.connect(self.addCart)”,但现在它不会打开。
“MainWindow”对象没有“addCart”属性。
class MainWindow(QtWidgets.QMainWindow, Ui_MainWindow):
def __init__(self, parent=None):
QtWidgets.QMainWindow.__init__(self, parent=parent)
self.setupUi(self)
self.Addtocart.clicked.connect(self.addCart)
def addcart(self):
style = self.comboBox_6.currentText()
name = self.lineEdit_10.text()
color = self.lineEdit_11.text()
size = self.comboBox_7.currentText()
text = "style: {style}, name: {name}, color: {color}, size: {size}".format(style=style, name=name, color=color, size=size)
self.plainTextEdit.appendPlainText(text)
【问题讨论】:
-
请缩进你的代码,缩进在python中很重要。