Lii_Jan
2022-04-24 04:56
采纳率: 100%
浏览 78
已结题

pycharm使用Qtdesigner将ui转换为py文件出现了不存在的模块

问题遇到的现象和发生背景

是这样的,今天刚着手尝试下Qtdesigner,后续也配置好了Pyuic,Pyrccs,使用designer绘制过程没有问题,使用Pyuic时第一次报过错,但是通过查询问题得到了解决,最后py文件是转出来了,但是居然不能调用?我看了下转的文件,是多出来了个我没有命名过一个模块“import midterm_rc”(ps.midterm是我的文件名),真的是不知道哪里出问题才来请教,感谢各位的帮忙!
(上述三个工具的工作环境我都设置在midterm文件夹下)
这是文件夹的目录:

img

问题相关代码

这是转为py的文件:

# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'Stock_Single_Modify.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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(419, 405)
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        self.centralwidget.setObjectName("centralwidget")
        self.sto_name = QtWidgets.QLabel(self.centralwidget)
        self.sto_name.setGeometry(QtCore.QRect(110, 60, 51, 16))
        self.sto_name.setObjectName("sto_name")
        self.sto_date = QtWidgets.QLabel(self.centralwidget)
        self.sto_date.setGeometry(QtCore.QRect(110, 120, 54, 12))
        self.sto_date.setObjectName("sto_date")
        self.sto_hgest_price = QtWidgets.QLabel(self.centralwidget)
        self.sto_hgest_price.setGeometry(QtCore.QRect(110, 150, 71, 16))
        self.sto_hgest_price.setObjectName("sto_hgest_price")
        self.sto_lowest_price = QtWidgets.QLabel(self.centralwidget)
        self.sto_lowest_price.setGeometry(QtCore.QRect(110, 180, 71, 16))
        self.sto_lowest_price.setObjectName("sto_lowest_price")
        self.sto_todaybegin_price = QtWidgets.QLabel(self.centralwidget)
        self.sto_todaybegin_price.setGeometry(QtCore.QRect(110, 210, 71, 16))
        self.sto_todaybegin_price.setObjectName("sto_todaybegin_price")
        self.sto_yestend_price = QtWidgets.QLabel(self.centralwidget)
        self.sto_yestend_price.setGeometry(QtCore.QRect(110, 240, 71, 16))
        self.sto_yestend_price.setObjectName("sto_yestend_price")
        self.sto_done_price = QtWidgets.QLabel(self.centralwidget)
        self.sto_done_price.setGeometry(QtCore.QRect(120, 300, 41, 16))
        self.sto_done_price.setObjectName("sto_done_price")
        self.sto_code = QtWidgets.QLabel(self.centralwidget)
        self.sto_code.setGeometry(QtCore.QRect(110, 90, 61, 16))
        self.sto_code.setObjectName("sto_code")
        self.sto_done_num = QtWidgets.QLabel(self.centralwidget)
        self.sto_done_num.setGeometry(QtCore.QRect(120, 270, 41, 16))
        self.sto_done_num.setObjectName("sto_done_num")
        self.name_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.name_edit.setGeometry(QtCore.QRect(200, 60, 113, 20))
        self.name_edit.setObjectName("name_edit")
        self.code_eidt = QtWidgets.QLineEdit(self.centralwidget)
        self.code_eidt.setGeometry(QtCore.QRect(200, 90, 113, 20))
        self.code_eidt.setObjectName("code_eidt")
        self.date_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.date_edit.setGeometry(QtCore.QRect(200, 120, 113, 20))
        self.date_edit.setObjectName("date_edit")
        self.hgest_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.hgest_edit.setGeometry(QtCore.QRect(200, 150, 111, 20))
        self.hgest_edit.setObjectName("hgest_edit")
        self.lowest_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.lowest_edit.setGeometry(QtCore.QRect(200, 180, 113, 20))
        self.lowest_edit.setObjectName("lowest_edit")
        self.todaybegin_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.todaybegin_edit.setGeometry(QtCore.QRect(200, 210, 113, 20))
        self.todaybegin_edit.setObjectName("todaybegin_edit")
        self.yestend_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.yestend_edit.setGeometry(QtCore.QRect(200, 240, 113, 20))
        self.yestend_edit.setObjectName("yestend_edit")
        self.done_num_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.done_num_edit.setGeometry(QtCore.QRect(200, 270, 113, 20))
        self.done_num_edit.setObjectName("done_num_edit")
        self.done_price_edit = QtWidgets.QLineEdit(self.centralwidget)
        self.done_price_edit.setGeometry(QtCore.QRect(200, 300, 113, 20))
        self.done_price_edit.setObjectName("done_price_edit")
        self.btn_back = QtWidgets.QPushButton(self.centralwidget)
        self.btn_back.setGeometry(QtCore.QRect(80, 340, 75, 23))
        self.btn_back.setObjectName("btn_back")
        self.btn_keeper = QtWidgets.QPushButton(self.centralwidget)
        self.btn_keeper.setGeometry(QtCore.QRect(310, 340, 75, 23))
        self.btn_keeper.setObjectName("btn_keeper")
        self.listWidget = QtWidgets.QListWidget(self.centralwidget)
        self.listWidget.setGeometry(QtCore.QRect(-430, -420, 861, 881))
        self.listWidget.setMaximumSize(QtCore.QSize(861, 881))
        self.listWidget.setStyleSheet("background-image: url(:/1.webp.jpg);")
        self.listWidget.setObjectName("listWidget")
        self.listWidget.raise_()
        self.sto_name.raise_()
        self.sto_date.raise_()
        self.sto_hgest_price.raise_()
        self.sto_lowest_price.raise_()
        self.sto_todaybegin_price.raise_()
        self.sto_yestend_price.raise_()
        self.sto_done_price.raise_()
        self.sto_code.raise_()
        self.sto_done_num.raise_()
        self.name_edit.raise_()
        self.code_eidt.raise_()
        self.date_edit.raise_()
        self.hgest_edit.raise_()
        self.lowest_edit.raise_()
        self.todaybegin_edit.raise_()
        self.yestend_edit.raise_()
        self.done_num_edit.raise_()
        self.done_price_edit.raise_()
        self.btn_back.raise_()
        self.btn_keeper.raise_()
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 419, 22))
        self.menubar.setObjectName("menubar")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow"))
        self.sto_name.setText(_translate("MainWindow", "股票名称:"))
        self.sto_date.setText(_translate("MainWindow", "股票日期:"))
        self.sto_hgest_price.setText(_translate("MainWindow", "本日最高价:"))
        self.sto_lowest_price.setText(_translate("MainWindow", "本日最低价:"))
        self.sto_todaybegin_price.setText(_translate("MainWindow", "今日开盘价:"))
        self.sto_yestend_price.setText(_translate("MainWindow", "昨日收盘价:"))
        self.sto_done_price.setText(_translate("MainWindow", "成交额:"))
        self.sto_code.setText(_translate("MainWindow", "股票代码:"))
        self.sto_done_num.setText(_translate("MainWindow", "成交量:"))
        self.btn_back.setText(_translate("MainWindow", "返回"))
        self.btn_keeper.setText(_translate("MainWindow", "保存"))
import midterm_rc
运行结果及报错内容

img

我想要达到的结果

能运行出来就好呀!(இдஇ`) 

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题