Qvint01
@Qvint01

Поможете с PyQt5?

Привет, решил тут попробовать PyQt5, но проблема в том что я всё установил, скомпилировал .ui в .py,
но не могу присоединить его к 'основному коду', в видео которые я смотрел, была версия ниже PyQt5 и тех кусков кода уже нет.

Не подскажите как присоединить?

P.S Код:
spoiler

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

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


from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_Form(object):
    def setupUi(self, Form):
        Form.setObjectName("Form")
        Form.resize(300, 300)
        Form.setMinimumSize(QtCore.QSize(300, 300))
        Form.setMaximumSize(QtCore.QSize(300, 300))
        Form.setStyleSheet("QPushButton {\n"
"    background-color: white;\n"
"    with: 75px;\n"
"    height: 50px;\n"
"    font-size: 14px;\n"
"    font-weigh: bold;\n"
"    border: none;\n"
"    text-align: center;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"background-color: silver;\n"
"}\n"
"\n"
"QPushButton:pressed {\n"
" color: white;\n"
"}\n"
"\n"
"QLineEdit {\n"
"    font-size:16px;\n"
"    font-weigh: bold;\n"
"}")
        self.gridLayoutWidget = QtWidgets.QWidget(Form)
        self.gridLayoutWidget.setGeometry(QtCore.QRect(10, 60, 231, 231))
        self.gridLayoutWidget.setObjectName("gridLayoutWidget")
        self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget)
        self.gridLayout.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
        self.gridLayout.setContentsMargins(0, 0, 0, 0)
        self.gridLayout.setVerticalSpacing(0)
        self.gridLayout.setObjectName("gridLayout")
        self.pushButton = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton.setObjectName("pushButton")
        self.gridLayout.addWidget(self.pushButton, 1, 0, 1, 1)
        self.pushButton_7 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_7.setObjectName("pushButton_7")
        self.gridLayout.addWidget(self.pushButton_7, 0, 1, 1, 1)
        self.pushButton_9 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_9.setObjectName("pushButton_9")
        self.gridLayout.addWidget(self.pushButton_9, 2, 1, 1, 1)
        self.pushButton_22 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_22.setObjectName("pushButton_22")
        self.gridLayout.addWidget(self.pushButton_22, 3, 1, 1, 1)
        self.pushButton_2 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_2.setObjectName("pushButton_2")
        self.gridLayout.addWidget(self.pushButton_2, 2, 0, 1, 1)
        self.pushButton_12 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_12.setStyleSheet("")
        self.pushButton_12.setObjectName("pushButton_12")
        self.gridLayout.addWidget(self.pushButton_12, 0, 2, 1, 1)
        self.pushButton_3 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_3.setMinimumSize(QtCore.QSize(0, 0))
        self.pushButton_3.setObjectName("pushButton_3")
        self.gridLayout.addWidget(self.pushButton_3, 0, 0, 1, 1)
        self.pushButton_8 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_8.setObjectName("pushButton_8")
        self.gridLayout.addWidget(self.pushButton_8, 1, 1, 1, 1)
        self.pushButton_10 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_10.setObjectName("pushButton_10")
        self.gridLayout.addWidget(self.pushButton_10, 2, 2, 1, 1)
        self.pushButton_11 = QtWidgets.QPushButton(self.gridLayoutWidget)
        self.pushButton_11.setObjectName("pushButton_11")
        self.gridLayout.addWidget(self.pushButton_11, 1, 2, 1, 1)
        self.lineEdit = QtWidgets.QLineEdit(Form)
        self.lineEdit.setGeometry(QtCore.QRect(10, 10, 281, 41))
        self.lineEdit.setObjectName("lineEdit")
        self.verticalLayoutWidget = QtWidgets.QWidget(Form)
        self.verticalLayoutWidget.setGeometry(QtCore.QRect(250, 60, 41, 231))
        self.verticalLayoutWidget.setObjectName("verticalLayoutWidget")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.verticalLayoutWidget)
        self.verticalLayout.setContentsMargins(0, 5, 0, 0)
        self.verticalLayout.setObjectName("verticalLayout")
        self.pushButton_25 = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.pushButton_25.setObjectName("pushButton_25")
        self.verticalLayout.addWidget(self.pushButton_25)
        self.pushButton_24 = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.pushButton_24.setObjectName("pushButton_24")
        self.verticalLayout.addWidget(self.pushButton_24)
        self.pushButton_23 = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.pushButton_23.setObjectName("pushButton_23")
        self.verticalLayout.addWidget(self.pushButton_23)
        self.pushButton_26 = QtWidgets.QPushButton(self.verticalLayoutWidget)
        self.pushButton_26.setObjectName("pushButton_26")
        self.verticalLayout.addWidget(self.pushButton_26)

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

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "Form"))
        self.pushButton.setText(_translate("Form", "4"))
        self.pushButton_7.setText(_translate("Form", "8"))
        self.pushButton_9.setText(_translate("Form", "2"))
        self.pushButton_22.setText(_translate("Form", "0"))
        self.pushButton_2.setText(_translate("Form", "1"))
        self.pushButton_12.setText(_translate("Form", "8"))
        self.pushButton_3.setText(_translate("Form", "7"))
        self.pushButton_8.setText(_translate("Form", "5"))
        self.pushButton_10.setText(_translate("Form", "3"))
        self.pushButton_11.setText(_translate("Form", "6"))
        self.pushButton_25.setText(_translate("Form", "+"))
        self.pushButton_24.setText(_translate("Form", "-"))
        self.pushButton_23.setText(_translate("Form", "*"))
        self.pushButton_26.setText(_translate("Form", "/"))

  • Вопрос задан
  • 76 просмотров
Решения вопроса 1
Qvint01
@Qvint01 Автор вопроса
Решил проблему.

Оказалось что я не так компилировал код, если что вот как правильно:
python -m PyQt5.uic.pyuic -x filemane.ui -o filename.py
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

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

Похожие вопросы
29 нояб. 2024, в 07:44
20000 руб./за проект
29 нояб. 2024, в 04:45
5000 руб./за проект
29 нояб. 2024, в 04:42
5000 руб./за проект