Задать вопрос
@007SHrEK007

Не запускается файл после конвертации из .ui в .py?

Запускаю команду pyuic5 -x test.ui -o test.py появляется файл test.py, но он не работает, там есть строка import test_rc на которую ругается консоль если её убрать, файл запуститься но будет просто белый
# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'test.ui'
#
# Created by: PyQt5 UI code generator 5.15.11
#
# 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_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(850, 700)
        Dialog.setStyleSheet("background-image: url(:/newPrefix/test/back-2.png);")
        self.pushButton_4 = QtWidgets.QPushButton(Dialog)
        self.pushButton_4.setGeometry(QtCore.QRect(110, 110, 601, 181))
        self.pushButton_4.setStyleSheet("QPushButton {\n"
"    background-color: rgba(255,255,255,0);\n"
"    border: none;\n"
"}\n"
"QPushButton {\n"
"    background-image: url(:/newPrefix/test/menu3.png);\n"
"    background-repeat: no-repeat;\n"
"}")
        self.pushButton_4.setText("")
        self.pushButton_4.setIconSize(QtCore.QSize(600, 500))
        self.pushButton_4.setObjectName("pushButton_4")
        self.pushButton_2 = QtWidgets.QPushButton(Dialog)
        self.pushButton_2.setGeometry(QtCore.QRect(150, 520, 261, 91))
        self.pushButton_2.setStyleSheet("QPushButton {\n"
"    background-image: url(:/newPrefix/test/settings-black.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:hover {\n"
"    background-image: url(:/newPrefix/test/settings-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:pressed {\n"
"    background-image: url(:/newPrefix/test/settings-pressed-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton {\n"
"    background-color: rgba(255,255,255,0);\n"
"    border: none;\n"
"}")
        self.pushButton_2.setText("")
        self.pushButton_2.setFlat(False)
        self.pushButton_2.setObjectName("pushButton_2")
        self.pushButton_3 = QtWidgets.QPushButton(Dialog)
        self.pushButton_3.setGeometry(QtCore.QRect(420, 520, 261, 91))
        self.pushButton_3.setStyleSheet("QPushButton {\n"
"    background-image: url(:/newPrefix/test/exit-black.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:hover {\n"
"    background-image: url(:/newPrefix/test/exit-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:pressed {\n"
"    background-image: url(:/newPrefix/test/exit-pressed-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton {\n"
"    background-color: rgba(255,255,255,0);\n"
"    border: none;\n"
"}")
        self.pushButton_3.setText("")
        self.pushButton_3.setObjectName("pushButton_3")
        self.pushButton = QtWidgets.QPushButton(Dialog)
        self.pushButton.setGeometry(QtCore.QRect(150, 420, 531, 81))
        self.pushButton.setStyleSheet("QPushButton {\n"
"    background-image: url(:/newPrefix/test/join-game-black.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:hover {\n"
"    background-image: url(:/newPrefix/test/join-game-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton:pressed {\n"
"    background-image: url(:/newPrefix/test/join-game-pressed-white.png);\n"
"    background-repeat: no-repeat;\n"
"}\n"
"QPushButton {\n"
"    background-color: rgba(255,255,255,0);\n"
"    border: none;\n"
"}")
        self.pushButton.setText("")
        self.pushButton.setAutoDefault(True)
        self.pushButton.setFlat(False)
        self.pushButton.setObjectName("pushButton")

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

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "Dialog"))
import test_rc


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_())
  • Вопрос задан
  • 97 просмотров
Подписаться 1 Простой Комментировать
Решения вопроса 1
Viji
@Viji
DevOps Engineer
Думаю надо еще файл скомпилить

https://stackoverflow.com/questions/41301204/impor...
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Похожие вопросы
08 дек. 2024, в 22:06
3000 руб./за проект
08 дек. 2024, в 21:02
13000 руб./за проект
08 дек. 2024, в 21:00
2000 руб./за проект