With your ui
run:
pyside6-uic my.ui -o form_custom.py
got form_custom.py
:
# -*- coding: utf-8 -*-
################################################################################
## Form generated from reading UI file 'my.ui'
##
## Created by: Qt User Interface Compiler version 6.7.2
##
## WARNING! All changes made in this file will be lost when recompiling UI file!
################################################################################
from PySide6.QtCore import (QCoreApplication, QDate, QDateTime, QLocale,
QMetaObject, QObject, QPoint, QRect,
QSize, QTime, QUrl, Qt)
from PySide6.QtGui import (QBrush, QColor, QConicalGradient, QCursor,
QFont, QFontDatabase, QGradient, QIcon,
QImage, QKeySequence, QLinearGradient, QPainter,
QPalette, QPixmap, QRadialGradient, QTransform)
from PySide6.QtWidgets import (QApplication, QGridLayout, QHBoxLayout, QPushButton,
QSizePolicy, QWidget)
class Ui_Form_custom(object):
def setupUi(self, Form_custom):
if not Form_custom.objectName():
Form_custom.setObjectName(u"Form_custom")
Form_custom.resize(368, 344)
sizePolicy = QSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)
sizePolicy.setHorizontalStretch(1)
sizePolicy.setVerticalStretch(1)
sizePolicy.setHeightForWidth(Form_custom.sizePolicy().hasHeightForWidth())
Form_custom.setSizePolicy(sizePolicy)
Form_custom.setSizeIncrement(QSize(1, 1))
Form_custom.setBaseSize(QSize(1, 1))
self.horizontalLayout = QHBoxLayout(Form_custom)
self.horizontalLayout.setObjectName(u"horizontalLayout")
self.widget = QWidget(Form_custom)
self.widget.setObjectName(u"widget")
sizePolicy.setHeightForWidth(self.widget.sizePolicy().hasHeightForWidth())
self.widget.setSizePolicy(sizePolicy)
self.widget.setMinimumSize(QSize(0, 200))
self.widget.setSizeIncrement(QSize(1, 1))
self.widget.setBaseSize(QSize(1, 1))
self.gridLayout = QGridLayout(self.widget)
self.gridLayout.setObjectName(u"gridLayout")
self.pushButton = QPushButton(self.widget)
self.pushButton.setObjectName(u"pushButton")
self.gridLayout.addWidget(self.pushButton, 0, 0, 1, 1)
self.horizontalLayout.addWidget(self.widget)
self.retranslateUi(Form_custom)
QMetaObject.connectSlotsByName(Form_custom)
# setupUi
def retranslateUi(self, Form_custom):
Form_custom.setWindowTitle(QCoreApplication.translate("Form_custom", u"Form", None))
self.pushButton.setText(QCoreApplication.translate("Form_custom", u"PushButton_custom", None))
# retranslateUi
than I make my.py
:
import sys
from PySide6.QtWidgets import QApplication, QWidget
from form_custom import Ui_Form_custom
class MainWindow(QWidget, Ui_Form_custom):
def __init__(self):
super().__init__()
self.setupUi(self)
app = QApplication(sys.argv)
window = MainWindow()
window.show()
app.exec_()
when I run it:
So, what you try to do?