本文主要是介绍第四天学 pyside2,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
先看我写的界面
简单测试一下功能
接收正常
下面是代码,详细功能还在实现中,已经有了模版。
# -*- coding: utf-8 -*-# Form implementation generated from reading ui file '1.ui'
#
# Created by: PyQt5 UI code generator 5.15.6
#
# 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
import sysclass Ui_Form(object):def setupUi(self, Form):Form.setObjectName("Form")Form.resize(616, 498)self.plainTextEdit = QtWidgets.QPlainTextEdit(Form)self.plainTextEdit.setGeometry(QtCore.QRect(180, 110, 381, 31))self.plainTextEdit.setObjectName("plainTextEdit")self.label = QtWidgets.QLabel(Form)self.label.setGeometry(QtCore.QRect(10, 110, 181, 20))self.label.setObjectName("label")self.label_2 = QtWidgets.QLabel(Form)self.label_2.setGeometry(QtCore.QRect(160, 0, 251, 61))self.label_2.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)self.label_2.setObjectName("label_2")self.label_3 = QtWidgets.QLabel(Form)self.label_3.setGeometry(QtCore.QRect(50, 310, 471, 231))self.label_3.setObjectName("label_3")self.widget = QtWidgets.QWidget(Form)self.widget.setGeometry(QtCore.QRect(40, 170, 341, 43))self.widget.setObjectName("widget")self.horizontalLayout = QtWidgets.QHBoxLayout(self.widget)self.horizontalLayout.setContentsMargins(0, 0, 0, 0)self.horizontalLayout.setObjectName("horizontalLayout")self.radioButton = QtWidgets.QRadioButton(self.widget)self.radioButton.setMinimumSize(QtCore.QSize(91, 41))self.radioButton.setObjectName("radioButton")self.buttonGroup = QtWidgets.QButtonGroup(Form)self.buttonGroup.setObjectName("buttonGroup")self.buttonGroup.addButton(self.radioButton)self.horizontalLayout.addWidget(self.radioButton)self.radioButton_2 = QtWidgets.QRadioButton(self.widget)self.radioButton_2.setObjectName("radioButton_2")self.buttonGroup.addButton(self.radioButton_2)self.horizontalLayout.addWidget(self.radioButton_2)self.widget1 = QtWidgets.QWidget(Form)self.widget1.setGeometry(QtCore.QRect(40, 220, 401, 71))self.widget1.setObjectName("widget1")self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.widget1)self.horizontalLayout_2.setContentsMargins(0, 0, 0, 0)self.horizontalLayout_2.setObjectName("horizontalLayout_2")self.pushButton = QtWidgets.QPushButton(self.widget1)self.pushButton.setObjectName("pushButton")self.horizontalLayout_2.addWidget(self.pushButton)self.pushButton_2 = QtWidgets.QPushButton(self.widget1)self.pushButton_2.setObjectName("pushButton_2")self.horizontalLayout_2.addWidget(self.pushButton_2)self.pushButton_3 = QtWidgets.QPushButton(self.widget1)self.pushButton_3.setObjectName("pushButton_3")self.horizontalLayout_2.addWidget(self.pushButton_3)self.retranslateUi(Form)QtCore.QMetaObject.connectSlotsByName(Form)def retranslateUi(self, Form):_translate = QtCore.QCoreApplication.translateForm.setWindowTitle(_translate("Form", "Form"))self.label.setText(_translate("Form", "请输入 图片 的 路径"))self.label_2.setText(_translate("Form", " yolox 可视化 界面 "))self.label_3.setText(_translate("Form", " 显示界面中"))self.radioButton.setText(_translate("Form", "yolox_s"))self.radioButton_2.setText(_translate("Form", "yolox_m"))self.buttonGroup.buttonClicked.connect(self.qz)self.pushButton.setText(_translate("Form", "测试"))self.pushButton.clicked.connect(self.ceshi)self.pushButton_2.setText(_translate("Form", "显示"))self.pushButton_2.clicked.connect(self.xianshi)self.pushButton_3.setText(_translate("Form", "关闭软件"))self.pushButton_3.clicked.connect(self.guanbi)def ceshi(self):self.pushButton.setEnabled(False)self.inof=self.plainTextEdit.toPlainText()print(self.inof)print("测试中")self.pushButton.setEnabled(True)def xianshi(self):print("显示")def guanbi(self):print("软件已关闭")exit(0)def qz(self):self.neir=self.buttonGroup.checkedButton().text()print("你选择的模型是")print(self.neir)if self.neir=='yolox_s':a=1if self.neir=='yolox_m':a=2if __name__ == '__main__':if __name__ == "__main__":app = QtWidgets.QApplication(sys.argv)widget = QtWidgets.QWidget()ui = Ui_Form()ui.setupUi(widget)widget.show()sys.exit(app.exec_())
这篇关于第四天学 pyside2的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!