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

运行时报错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日

悬赏问题

  • ¥15 远程安装一下vasp
  • ¥15 自己做的代码上传图片时,报错
  • ¥15 Lingo线性规划模型怎么搭建
  • ¥15 关于#python#的问题,请各位专家解答!区间型正向化
  • ¥15 unity从3D升级到urp管线,打包ab包后,材质全部变紫色
  • ¥50 comsol温度场仿真无法模拟微米级激光光斑
  • ¥15 上传图片时提交的存储类型
  • ¥15 VB.NET如何绘制倾斜的椭圆
  • ¥15 arbotix没有/cmd_vel话题
  • ¥15 odoo17的分包重新供应路线如何设置?可从销售订单中实时直接触发采购订单或相关单据