代码拉取完成,页面将自动刷新
import ctypes
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QIcon
from PyQt5.QtWidgets import QFileDialog, QMessageBox
class Setting_MainWindow(object):
def __init__(self):
super(Setting_MainWindow, self).__init__()
self.str = 0
def setupUi(self, MainWindow):
MainWindow.setObjectName("MainWindow")
# 设置左上角窗口图标
self.setWindowIcon(QIcon('./logo.png'))
# 设置任务栏图标
ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID("myappid")
MainWindow.resize(570, 340)
self.centralwidget = QtWidgets.QWidget(MainWindow)
self.centralwidget.setObjectName("centralwidget")
self.gridLayout_2 = QtWidgets.QGridLayout(self.centralwidget)
self.gridLayout_2.setObjectName("gridLayout_2")
self.gridLayout = QtWidgets.QGridLayout()
self.gridLayout.setObjectName("gridLayout")
self.pushButton_5 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_5.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton_5.setObjectName("pushButton_5")
self.gridLayout.addWidget(self.pushButton_5, 5, 0, 1, 1)
self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
self.horizontalLayout_5.setObjectName("horizontalLayout_5")
self.label_5 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth())
self.label_5.setSizePolicy(sizePolicy)
self.label_5.setStyleSheet("font: 12pt \"Microsoft Himalaya\";")
self.label_5.setObjectName("label_5")
self.horizontalLayout_5.addWidget(self.label_5)
self.radioButton = QtWidgets.QRadioButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.radioButton.sizePolicy().hasHeightForWidth())
self.radioButton.setSizePolicy(sizePolicy)
self.radioButton.setStyleSheet("font: 15pt \"Microsoft Himalaya\";")
self.radioButton.setObjectName("radioButton")
self.horizontalLayout_5.addWidget(self.radioButton)
self.radioButton_2 = QtWidgets.QRadioButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.radioButton_2.sizePolicy().hasHeightForWidth())
self.radioButton_2.setSizePolicy(sizePolicy)
self.radioButton_2.setStyleSheet("font: 15pt \"Microsoft Himalaya\";")
self.radioButton_2.setObjectName("radioButton_2")
self.horizontalLayout_5.addWidget(self.radioButton_2)
self.horizontalLayout_5.setStretch(0, 4)
self.horizontalLayout_5.setStretch(1, 5)
self.horizontalLayout_5.setStretch(2, 5)
self.gridLayout.addLayout(self.horizontalLayout_5, 4, 0, 1, 1)
self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
self.horizontalLayout_3.setObjectName("horizontalLayout_3")
self.label_3 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_3.sizePolicy().hasHeightForWidth())
self.label_3.setSizePolicy(sizePolicy)
self.label_3.setStyleSheet("font: 12pt \"Microsoft Himalaya\";")
self.label_3.setObjectName("label_3")
self.horizontalLayout_3.addWidget(self.label_3)
self.lineEdit_3 = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_3.sizePolicy().hasHeightForWidth())
self.lineEdit_3.setSizePolicy(sizePolicy)
self.lineEdit_3.setStyleSheet("font: 13pt \"Microsoft Himalaya\";")
self.lineEdit_3.setObjectName("lineEdit_3")
self.horizontalLayout_3.addWidget(self.lineEdit_3)
self.pushButton_3 = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton_3.sizePolicy().hasHeightForWidth())
self.pushButton_3.setSizePolicy(sizePolicy)
self.pushButton_3.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton_3.setObjectName("pushButton_3")
self.horizontalLayout_3.addWidget(self.pushButton_3)
self.horizontalLayout_3.setStretch(0, 4)
self.horizontalLayout_3.setStretch(1, 7)
self.horizontalLayout_3.setStretch(2, 2)
self.gridLayout.addLayout(self.horizontalLayout_3, 2, 0, 1, 1)
self.horizontalLayout = QtWidgets.QHBoxLayout()
self.horizontalLayout.setObjectName("horizontalLayout")
self.label = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())
self.label.setSizePolicy(sizePolicy)
self.label.setStyleSheet("font: 12pt \"Microsoft Himalaya\";")
self.label.setObjectName("label")
self.horizontalLayout.addWidget(self.label)
self.lineEdit = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit.sizePolicy().hasHeightForWidth())
self.lineEdit.setSizePolicy(sizePolicy)
self.lineEdit.setStyleSheet("font: 13pt \"Microsoft Himalaya\";")
self.lineEdit.setObjectName("lineEdit")
self.horizontalLayout.addWidget(self.lineEdit)
self.pushButton = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
self.pushButton.setSizePolicy(sizePolicy)
self.pushButton.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton.setObjectName("pushButton")
self.horizontalLayout.addWidget(self.pushButton)
self.horizontalLayout.setStretch(0, 4)
self.horizontalLayout.setStretch(1, 7)
self.horizontalLayout.setStretch(2, 2)
self.gridLayout.addLayout(self.horizontalLayout, 0, 0, 1, 1)
self.horizontalLayout_2 = QtWidgets.QHBoxLayout()
self.horizontalLayout_2.setObjectName("horizontalLayout_2")
self.label_2 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())
self.label_2.setSizePolicy(sizePolicy)
self.label_2.setStyleSheet("font: 12pt \"Microsoft Himalaya\";")
self.label_2.setObjectName("label_2")
self.horizontalLayout_2.addWidget(self.label_2)
self.lineEdit_2 = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_2.sizePolicy().hasHeightForWidth())
self.lineEdit_2.setSizePolicy(sizePolicy)
self.lineEdit_2.setStyleSheet("font: 13pt \"Microsoft Himalaya\";")
self.lineEdit_2.setObjectName("lineEdit_2")
self.horizontalLayout_2.addWidget(self.lineEdit_2)
self.pushButton_2 = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())
self.pushButton_2.setSizePolicy(sizePolicy)
self.pushButton_2.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton_2.setObjectName("pushButton_2")
self.horizontalLayout_2.addWidget(self.pushButton_2)
self.horizontalLayout_2.setStretch(0, 4)
self.horizontalLayout_2.setStretch(1, 7)
self.horizontalLayout_2.setStretch(2, 2)
self.gridLayout.addLayout(self.horizontalLayout_2, 1, 0, 1, 1)
self.horizontalLayout_4 = QtWidgets.QHBoxLayout()
self.horizontalLayout_4.setObjectName("horizontalLayout_4")
self.label_4 = QtWidgets.QLabel(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.label_4.sizePolicy().hasHeightForWidth())
self.label_4.setSizePolicy(sizePolicy)
self.label_4.setStyleSheet("font: 12pt \"Microsoft Himalaya\";")
self.label_4.setObjectName("label_4")
self.horizontalLayout_4.addWidget(self.label_4)
self.lineEdit_4 = QtWidgets.QLineEdit(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.lineEdit_4.sizePolicy().hasHeightForWidth())
self.lineEdit_4.setSizePolicy(sizePolicy)
self.lineEdit_4.setStyleSheet("font: 13pt \"Microsoft Himalaya\";")
self.lineEdit_4.setObjectName("lineEdit_4")
self.horizontalLayout_4.addWidget(self.lineEdit_4)
self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget)
sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding)
sizePolicy.setHorizontalStretch(0)
sizePolicy.setVerticalStretch(0)
sizePolicy.setHeightForWidth(self.pushButton_4.sizePolicy().hasHeightForWidth())
self.pushButton_4.setSizePolicy(sizePolicy)
self.pushButton_4.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton_4.setObjectName("pushButton_4")
self.horizontalLayout_4.addWidget(self.pushButton_4)
self.horizontalLayout_4.setStretch(0, 4)
self.horizontalLayout_4.setStretch(1, 7)
self.horizontalLayout_4.setStretch(2, 2)
self.gridLayout.addLayout(self.horizontalLayout_4, 3, 0, 1, 1)
self.pushButton_6 = QtWidgets.QPushButton(self.centralwidget)
self.pushButton_6.setStyleSheet("font: 10pt \"Microsoft Himalaya\";")
self.pushButton_6.setObjectName("pushButton_6")
self.gridLayout.addWidget(self.pushButton_6, 6, 0, 1, 1)
self.gridLayout_2.addLayout(self.gridLayout, 0, 0, 1, 1)
MainWindow.setCentralWidget(self.centralwidget)
self.statusbar = QtWidgets.QStatusBar(MainWindow)
self.statusbar.setObjectName("statusbar")
MainWindow.setStatusBar(self.statusbar)
self.pushButton.clicked.connect(self.butt)
self.pushButton_2.clicked.connect(self.butt_2)
self.pushButton_3.clicked.connect(self.butt_3)
self.pushButton_4.clicked.connect(self.butt_4)
self.pushButton_5.clicked.connect(self.butt_5)
self.pushButton_6.clicked.connect(self.butt_6)
self.lineEdit.setReadOnly(True) # 设置LineEdit只读
self.lineEdit_2.setReadOnly(True) # 设置LineEdit只读
self.lineEdit_3.setReadOnly(True) # 设置LineEdit只读
self.lineEdit_4.setReadOnly(True) # 设置LineEdit只读
self.retranslateUi(MainWindow)
QtCore.QMetaObject.connectSlotsByName(MainWindow)
def retranslateUi(self, MainWindow):
_translate = QtCore.QCoreApplication.translate
MainWindow.setWindowTitle(_translate("MainWindow", "设置"))
self.pushButton_5.setText(_translate("MainWindow", "确定"))
self.label_5.setText(_translate("MainWindow", "运行设备:"))
self.radioButton.setText(_translate("MainWindow", "GPU"))
self.radioButton_2.setText(_translate("MainWindow", "CPU"))
self.label_3.setText(_translate("MainWindow", "识别模型权重路径:"))
self.pushButton_3.setText(_translate("MainWindow", "选择"))
self.label.setText(_translate("MainWindow", "检测模型权重路径:"))
self.pushButton.setText(_translate("MainWindow", "选择"))
self.label_2.setText(_translate("MainWindow", "分类模型权重路径:"))
self.pushButton_2.setText(_translate("MainWindow", "选择"))
self.label_4.setText(_translate("MainWindow", "字典文件路径:"))
self.pushButton_4.setText(_translate("MainWindow", "选择"))
self.pushButton_6.setText(_translate("MainWindow", "取消"))
def butt(self):
str_path = QFileDialog.getExistingDirectory(None, "选取文件夹", "")
self.lineEdit.setText(str_path)
def butt_2(self):
str_path = QFileDialog.getExistingDirectory(None, "选取文件夹", "")
self.lineEdit_2.setText(str_path)
def butt_3(self):
str_path = QFileDialog.getExistingDirectory(None, "选取文件夹", "")
self.lineEdit_3.setText(str_path)
def butt_4(self):
# str_path = QFileDialog.getExistingDirectory(None, "选取文件夹", "")
str_path, _ = QFileDialog.getOpenFileName(self, '打开文件', './results', '*')
self.lineEdit_4.setText(str_path)
def butt_5(self):
lis = []
if len(self.lineEdit.text()) != 0:
lis.append(self.lineEdit.text())
if len(self.lineEdit_2.text()) != 0:
lis.append(self.lineEdit_2.text())
if len(self.lineEdit_3.text()) != 0:
lis.append(self.lineEdit_3.text())
if len(self.lineEdit_4.text()) != 0:
lis.append(self.lineEdit_4.text())
if self.radioButton.isChecked():
lis.append('gpu')
elif self.radioButton_2.isChecked():
lis.append('cpu')
if len(lis) == 5:
lis.append('0')
lis.append('1')
lis.append('6')
lis.append('default')
lis_2 = ['det_model', 'cls_model', 'rec_model', 'rec_label_file', 'device', 'device_id', 'cls_bs', 'rec_bs',
'backend']
with open("model/parameters.ini", "w") as f:
for inx, i in enumerate(lis):
f.write(lis_2[inx] + ' ' + str(i) + '\n')
result = QMessageBox.question(None, '提示', '程序将进行重启,是否重启?',QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if result == QMessageBox.Yes:
self.colse()
else:
QMessageBox.critical(self, "错误", "请先选择全部参数!!!")
def butt_6(self):
self.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。