from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(682, 624) self.verticalLayout = QtWidgets.QVBoxLayout() # 创建V1 self.verticalLayout.setObjectName("verticalLayout") self.verticalLayout_2 = QtWidgets.QVBoxLayout(Form) # 创建V2 self.verticalLayout_2.setObjectName("verticalLayout_2") self.horizontalLayout = QtWidgets.QHBoxLayout() # 创建H1 self.horizontalLayout.setObjectName("horizontalLayout") self.horizontalLayout_2 = QtWidgets.QHBoxLayout() # 创建H2 self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.horizontalLayout_3 = QtWidgets.QHBoxLayout() # 创建H3 self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.radioButton = QtWidgets.QRadioButton(Form) # 创建radio1 self.radioButton.setObjectName("radioButton") self.radioButton_2 = QtWidgets.QRadioButton(Form) # 创建radio2 self.radioButton_2.setObjectName("radioButton_2") self.pushButton = QtWidgets.QPushButton(Form) # 创建Button self.pushButton.setObjectName("pushButton") spaceItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spaceItem2 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_3.addItem(spaceItem1) self.horizontalLayout_3.addWidget(self.pushButton) self.horizontalLayout_3.addItem(spaceItem2) spaceItem3 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spaceItem4 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout.addItem(spaceItem3) self.horizontalLayout.addWidget(self.radioButton) self.horizontalLayout.addWidget(self.radioButton_2) self.horizontalLayout.addItem(spaceItem4) spaceItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spaceItem6 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum) spaceItem7 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) spaceItem8 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding) self.verticalLayout.addItem(spaceItem7) self.verticalLayout.addItem(spaceItem8) self.horizontalLayout_2.addLayout(self.verticalLayout) self.horizontalLayout_2.addItem(spaceItem6) self.verticalLayout_2.addLayout(self.horizontalLayout) self.verticalLayout_2.addLayout(self.horizontalLayout_2) self.verticalLayout_2.addLayout(self.horizontalLayout_3) self.retranslateUi(Form) QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) self.radioButton.setText(_translate("Form", "RadioButton")) self.radioButton_2.setText(_translate("Form", "RadioButton")) self.pushButton.setText(_translate("Form", "PushButton")) if __name__ == "__main__": import sys app = QtWidgets.QApplication(sys.argv) Form = QtWidgets.QWidget() ui = Ui_Form() ui.setupUi(Form) Form.show() sys.exit(app.exec_())