Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/blackberry/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
转换为python的Pyqt5 Ui文件似乎不起作用_Python - Fatal编程技术网

转换为python的Pyqt5 Ui文件似乎不起作用

转换为python的Pyqt5 Ui文件似乎不起作用,python,Python,我在命令中使用了Pyuic5.exe pyuic5.exe-x filename.ui-o pythonfilename.py 这就是它放在python文件中的内容,但当我在python3中运行它时,它不起作用,即使我有-x使它可执行 这就是它放入python文件的内容 # -*- coding: utf-8 -*- # Form implementation generated from reading ui file '.\untitled.ui' # # Created by: PyQt

我在命令中使用了Pyuic5.exe

pyuic5.exe-x filename.ui-o pythonfilename.py

这就是它放在python文件中的内容,但当我在python3中运行它时,它不起作用,即使我有-x使它可执行

这就是它放入python文件的内容

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

# Form implementation generated from reading ui file '.\untitled.ui'
#
# Created by: PyQt5 UI code generator 5.14.1
#
# WARNING! All changes made in this file will be lost!


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(500, 400)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())
        Dialog.setSizePolicy(sizePolicy)
        Dialog.setSizeIncrement(QtCore.QSize(-23422, 0))
        Dialog.setStyleSheet("qdarkstyle.load_stylesheet()")
        self.Button1 = QtWidgets.QPushButton(Dialog)
        self.Button1.setGeometry(QtCore.QRect(60, 240, 91, 31))
        self.Button1.setMinimumSize(QtCore.QSize(91, 31))
        self.Button1.setObjectName("Button1")
        self.Button2 = QtWidgets.QPushButton(Dialog)
        self.Button2.setGeometry(QtCore.QRect(290, 240, 91, 31))
        self.Button2.setMinimumSize(QtCore.QSize(91, 31))
        self.Button2.setBaseSize(QtCore.QSize(250, 240))
        self.Button2.setObjectName("Button2")
        self.Button3 = QtWidgets.QPushButton(Dialog)
        self.Button3.setGeometry(QtCore.QRect(290, 310, 91, 31))
        self.Button3.setMinimumSize(QtCore.QSize(91, 31))
        self.Button3.setObjectName("Button3")
        self.Button4 = QtWidgets.QPushButton(Dialog)
        self.Button4.setGeometry(QtCore.QRect(60, 310, 91, 31))
        self.Button4.setMinimumSize(QtCore.QSize(91, 31))
        self.Button4.setObjectName("Button4")
        self.Question = QtWidgets.QLabel(Dialog)
        self.Question.setGeometry(QtCore.QRect(70, 40, 301, 61))
        font = QtGui.QFont()
        font.setPointSize(32)
        self.Question.setFont(font)
        self.Question.setObjectName("Question")

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

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
        self.Button1.setText(_translate("Dialog", "PushButton"))
        self.Button2.setText(_translate("Dialog", "PushButton"))
        self.Button3.setText(_translate("Dialog", "PushButton"))
        self.Button4.setText(_translate("Dialog", "PushButton"))
        self.Question.setText(_translate("Dialog", "TextLabel"))


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())


它可能缺少应用程序或显示在某处…

转换为可执行的python文件-

pyuic5-x-o pythonfilename.py filename.ui

将qrc转换为python文件:

pyrcc5-o pyfilename.py res.qrc


您不直接运行生成的文件,而是将
Ui\u Dialog
子类化到应用程序类中。欢迎使用StackOverflow!我知道你是一个新的投稿人,所以我建议你签出并提交。你能详细解释一下你所说的不起作用是什么意思吗?