Я использовал qt-desiger и перевел код на python с помощью
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\Scripts\pyside2-uic.exe -g python -o C:\test1.py C:\test.ui
Я попытался его запустить и вот что у меня получилось
from PySide2.QtCore import (QCoreApplication, QMetaObject, QObject, QPoint,
QRect, QSize, QUrl, Qt)
from PySide2.QtGui import (QBrush, QColor, QConicalGradient, QFont,
QFontDatabase, QIcon, QLinearGradient, QPalette, QPainter, QPixmap,
QRadialGradient)
from PySide2.QtWidgets import *
from PySide2.QtWidgets import QApplication,QWidget
import sys
class Ui_MainWindow(QWidget):
def setupUi(self, MainWindow):
if MainWindow.objectName():
MainWindow.setObjectName(u"MainWindow")
MainWindow.resize(764, 604)
self.centralwidget = QWidget(MainWindow)
self.centralwidget.setObjectName(u"centralwidget")
self.centralwidget.setEnabled(True)
self.centralwidget.setTabletTracking(False)
self.gridLayout = QGridLayout(self.centralwidget)
self.gridLayout.setObjectName(u"gridLayout")
self.gridLayout.setContentsMargins(0, 0, 0, 0)
self.verticalSpacer = QSpacerItem(20, 142, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.gridLayout.addItem(self.verticalSpacer, 0, 1, 1, 1)
self.horizontalSpacer = QSpacerItem(254, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.gridLayout.addItem(self.horizontalSpacer, 1, 0, 1, 1)
self.widget = QWidget(self.centralwidget)
self.widget.setObjectName(u"widget")
self.widget.setStyleSheet(u"background-color: rgb(239, 41, 41);")
self.verticalLayout = QVBoxLayout(self.widget)
self.verticalLayout.setObjectName(u"verticalLayout")
self.label = QLabel(self.widget)
self.label.setObjectName(u"label")
font = QFont()
font.setPointSize(21)
self.label.setFont(font)
self.label.setAlignment(Qt.AlignCenter)
self.verticalLayout.addWidget(self.label)
self.textEdit = QTextEdit(self.widget)
self.textEdit.setObjectName(u"textEdit")
self.textEdit.setStyleSheet(u"background-color: rgb(255, 255, 255);")
self.verticalLayout.addWidget(self.textEdit)
self.gridLayout.addWidget(self.widget, 1, 1, 1, 1)
self.verticalSpacer_2 = QSpacerItem(20, 141, QSizePolicy.Minimum, QSizePolicy.Expanding)
self.gridLayout.addItem(self.verticalSpacer_2, 2, 1, 1, 1)
self.horizontalSpacer_2 = QSpacerItem(254, 20, QSizePolicy.Expanding, QSizePolicy.Minimum)
self.gridLayout.addItem(self.horizontalSpacer_2, 1, 2, 1, 1)
self.gridLayout.setRowStretch(0, 1)
self.gridLayout.setRowStretch(2, 1)
self.gridLayout.setColumnStretch(0, 1)
self.gridLayout.setColumnStretch(2, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.menubar = QMenuBar(MainWindow)
self.menubar.setObjectName(u"menubar")
self.menubar.setGeometry(QRect(0, 0, 764, 22))
MainWindow.setMenuBar(self.menubar)
self.statusbar = QStatusBar(MainWindow)
self.statusbar.setObjectName(u"statusbar")
MainWindow.setStatusBar(self.statusbar)
self.retranslateUi(MainWindow)
QMetaObject.connectSlotsByName(MainWindow)
# setupUi
def retranslateUi(self, MainWindow):
MainWindow.setWindowTitle(QCoreApplication.translate("MainWindow", u"MainWindow", None))
self.label.setText(QCoreApplication.translate("MainWindow", u"Text", None))
# retranslateUi
my = QApplication(sys.argv)
window = Ui_MainWindow()
window.show()
my.exec_()
sys.exit(0)
Этот код выдает мне только белый экран а должен выдовать