from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Form(object): def setupUi(self, Form): Form.setObjectName("Form") Form.resize(1044, 729) self.gridLayoutWidget = QtWidgets.QWidget(Form) self.gridLayoutWidget.setGeometry(QtCore.QRect(19, 9, 991, 551)) self.gridLayoutWidget.setObjectName("gridLayoutWidget") self.gridLayout = QtWidgets.QGridLayout(self.gridLayoutWidget) self.gridLayout.setContentsMargins(0, 0, 0, 0) self.gridLayout.setObjectName("gridLayout") self.label = QtWidgets.QLabel(self.gridLayoutWidget) font = QtGui.QFont() font.setFamily("Adobe Arabic") font.setPointSize(26) self.label.setFont(font) self.label.setStyleSheet("background-color: rgb(255, 255, 127);") self.label.setAlignment(QtCore.Qt.AlignCenter) self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.label_2 = QtWidgets.QLabel(self.gridLayoutWidget) font = QtGui.QFont() font.setFamily("Adobe Arabic") font.setPointSize(26) self.label_2.setFont(font) self.label_2.setStyleSheet("background-color: rgb(170, 255, 255);") self.label_2.setAlignment(QtCore.Qt.AlignCenter) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 0, 1, 1, 1) self.pushButton = QtWidgets.QPushButton(Form) self.pushButton.setGeometry(QtCore.QRect(130, 640, 161, 51)) font = QtGui.QFont() font.setFamily("Adobe Arabic") font.setPointSize(18) self.pushButton.setFont(font) self.pushButton.setObjectName("pushButton") self.pushButton_2 = QtWidgets.QPushButton(Form) self.pushButton_2.setGeometry(QtCore.QRect(660, 640, 161, 51)) font = QtGui.QFont() font.setFamily("Adobe Arabic") font.setPointSize(18) self.pushButton_2.setFont(font) self.pushButton_2.setObjectName("pushButton_2") self.retranslateUi(Form) self.pushButton.clicked.connect(Form.Action) # type: ignore self.pushButton_2.clicked.connect(Form.UserNow) # type: ignore QtCore.QMetaObject.connectSlotsByName(Form) def retranslateUi(self, Form): _translate = QtCore.QCoreApplication.translate Form.setWindowTitle(_translate("Form", "Form")) self.label.setText(_translate("Form", "实时图像")) self.label_2.setText(_translate("Form", "抓取图像")) self.pushButton.setText(_translate("Form", "打开相机")) self.pushButton_2.setText(_translate("Form", "抓取图像"))
时间: 2023-06-24 16:06:39 浏览: 130
UI界面使用pyqt5
这是一个使用 PyQt5 模块编写的用户界面设计代码,包含一个主窗口、两个标签和两个按钮,具体功能为打开相机和抓取图像。其中,`setupUi()` 方法用于设置 UI 界面,`retranslateUi()` 方法用于翻译 UI 界面中的文字。`clicked.connect()` 方法用于连接按钮的点击事件,`Form.Action()` 和 `Form.UserNow()` 是两个自定义的方法,用于实现按钮的具体功能。
阅读全文