玛卡巴卡的小推车~ 2023-03-25 15:58 采纳率: 33.3%
浏览 95
已结题

运行时报错AttributeError: 'Ui_MainWindow' object has no attribute 'select_clicked'

运行时报错AttributeError: 'Ui_MainWindow' object has no attribute 'select_clicked'

img

img

img

img


```python
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'imge.ui'
#
# Created by: PyQt5 UI code generator 5.15.4
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.resize(800, 600)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.select = QtWidgets.QPushButton(self.centralwidget)
        self.select.setGeometry(QtCore.QRect(30, 30, 93, 28))
        self.select.setObjectName("select")
        self.key = QtWidgets.QPushButton(self.centralwidget)
        self.key.setGeometry(QtCore.QRect(30, 110, 93, 28))
        self.key.setObjectName("key")
        self.surf = QtWidgets.QPushButton(self.centralwidget)
        self.surf.setGeometry(QtCore.QRect(30, 200, 93, 28))
        self.surf.setObjectName("surf")
        self.match = QtWidgets.QPushButton(self.centralwidget)
        self.match.setGeometry(QtCore.QRect(30, 290, 93, 28))
        self.match.setObjectName("match")
        self.save = QtWidgets.QPushButton(self.centralwidget)
        self.save.setGeometry(QtCore.QRect(30, 380, 93, 28))
        self.save.setObjectName("save")
        self.labelimge = QtWidgets.QLabel(self.centralwidget)
        self.labelimge.setGeometry(QtCore.QRect(150, 20, 220, 220))
        self.labelimge.setObjectName("labelimge")
        self.labelkey = QtWidgets.QLabel(self.centralwidget)
        self.labelkey.setGeometry(QtCore.QRect(500, 20, 220, 220))
        self.labelkey.setObjectName("labelkey")
        self.labelsurf = QtWidgets.QLabel(self.centralwidget)
        self.labelsurf.setGeometry(QtCore.QRect(150, 240, 220, 220))
        self.labelsurf.setObjectName("labelsurf")
        self.labelmatch = QtWidgets.QLabel(self.centralwidget)
        self.labelmatch.setGeometry(QtCore.QRect(500, 240, 220, 220))
        self.labelmatch.setObjectName("labelmatch")
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 26))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        self.select.clicked.connect(self.select_clicked)
        self.key.clicked.connect(self.key_clicked)
        self.surf.clicked.connect(self.surf_clicked)
        self.match.clicked.connect(self.match_clicked)
        self.save.clicked.connect(self.save_clicked)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.select.setText(_translate("MainWindow", "选择图像"))
        self.key.setText(_translate("MainWindow", "画出关键点"))
        self.surf.setText(_translate("MainWindow", "描述特征点"))
        self.match.setText(_translate("MainWindow", "拼接图像"))
        self.save.setText(_translate("MainWindow", "保存图像"))
        self.labelimge.setText(_translate("MainWindow", "图片"))
        self.labelkey.setText(_translate("MainWindow", "关键点"))
        self.labelsurf.setText(_translate("MainWindow", "特征点"))
        self.labelmatch.setText(_translate("MainWindow", "拼接图"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())


```

  • 写回答

2条回答 默认 最新

  • 以山河作礼。 新星计划导师 2023-03-25 21:14
    关注

    这个错误是因为在你的Ui_MainWindow类中没有定义'select_clicked'方法,但在setupUi方法中尝试连接到它。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 4月8日
  • 已采纳回答 3月31日
  • 创建了问题 3月25日

悬赏问题

  • ¥20 Windows 驱动开发版本疑问相关
  • ¥15 MAC 未能打开磁盘映像
  • ¥15 fastcap使用,二维导体输入问题
  • ¥15 hosts修改后不能访问
  • ¥15 关于化学反应速率C++编译问题/FLUENT
  • ¥20 Yolov5训练报错
  • ¥15 Unity发布gzip压缩的webgl之后让浏览器可以正常显示画面
  • ¥15 ASP.net Gridview插件数据更新失败问题
  • ¥15 有没有人知道这种提示怎么关?现在不做ts项目了不知道咋关了,求解,现在我以前的js项目都是这种提示了
  • ¥15 为什么mysql做了碎片化处理data_free还是很高