我正在创建一个新的自动化测试软件,在开发过程中,我的逻辑部分运行良好,但是当我创建GUI时,显示出缺少一些元素。遵循我的代码:
Main.py
# -*- coding: utf-8 -*-
'''
@author: lo051449
V2.1
'''
from PyQt5 import QtCore, QtGui, QtWidgets
import View
from PyQt5 import QtWidgets
import sys
class Main(QtWidgets.QMainWindow, View.Ui_Form):
def __init__(self, parent=None):
super(Main, self).__init__(parent)
self.setupUi(self)
#FAZENDO LOGIN FICAR FIXO
self.login_Checkbox.setChecked(True)
self.login_Checkbox.stateChanged.connect(self.loginAlwaysChecked)
# funcionando apenas um dos dois
self.dahua_Checkbox.stateChanged.connect(self.DahuaChangeCheckBox)
self.jufeng_Checkbox.stateChanged.connect(self.changeJFCheckBox)
self.cam_Checkbox.stateChanged.connect(self.changeCamCheckBox)
self.nvr_Checkbox.stateChanged.connect(self.changeNVRCheckBox)
# botao de iniciar test inicia teste
self.stop_flag = False
if self.stop_flag == False:
self.startTest_Btn.clicked.connect(self.threadRun)
def main():
app = QtWidgets.QApplication(sys.argv)
form = Main()
form.show()
app.exec_()
if __name__ == '__main__':
main()
View.py
# -*- coding: utf-8 -*-
# Form implementation generated from reading ui file 'menuPrincipal.ui'
#
# Created by: PyQt5 UI code generator 5.11.2
#
# WARNING! All changes made in this file will be lost!
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Form(object):
def setupUi(self, Form):
Form.setObjectName("Form")
Form.resize(435, 570)
self.gridLayout = QtWidgets.QGridLayout(Form)
self.gridLayout.setObjectName("gridLayout")
self.progressBar = QtWidgets.QProgressBar(Form)
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.gridLayout.addWidget(self.progressBar, 17, 0, 1, 4)
spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout.addItem(spacerItem, 6, 3, 1, 1)
self.dahua_Checkbox = QtWidgets.QCheckBox(Form)
self.dahua_Checkbox.setObjectName("dahua_Checkbox")
self.gridLayout.addWidget(self.dahua_Checkbox, 1, 0, 1, 1)
self.startTest_Btn = QtWidgets.QPushButton(Form)
self.startTest_Btn.setObjectName("startTest_Btn")
self.gridLayout.addWidget(self.startTest_Btn, 16, 0, 1, 4)
self.label_3 = QtWidgets.QLabel(Form)
self.label_3.setObjectName("label_3")
self.gridLayout.addWidget(self.label_3, 6, 0, 1, 1)
self.port_TxtBox = QtWidgets.QLineEdit(Form)
self.port_TxtBox.setObjectName("port_TxtBox")
self.gridLayout.addWidget(self.port_TxtBox, 7, 2, 1, 1)
self.label_4 = QtWidgets.QLabel(Form)
self.label_4.setObjectName("label_4")
self.gridLayout.addWidget(self.label_4, 7, 0, 1, 1)
self.nvr_Checkbox = QtWidgets.QCheckBox(Form)
self.nvr_Checkbox.setObjectName("nvr_Checkbox")
self.gridLayout.addWidget(self.nvr_Checkbox, 4, 2, 1, 1)
self.supplier_Label = QtWidgets.QLabel(Form)
self.supplier_Label.setObjectName("supplier_Label")
self.gridLayout.addWidget(self.supplier_Label, 0, 0, 1, 1)
spacerItem1 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem1, 5, 2, 1, 1)
self.device_Label = QtWidgets.QLabel(Form)
self.device_Label.setObjectName("device_Label")
self.gridLayout.addWidget(self.device_Label, 3, 0, 1, 1)
spacerItem2 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem2, 2, 2, 1, 1)
spacerItem3 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout.addItem(spacerItem3, 8, 2, 1, 1)
self.ip_TxtBox = QtWidgets.QLineEdit(Form)
self.ip_TxtBox.setObjectName("ip_TxtBox")
self.gridLayout.addWidget(self.ip_TxtBox, 6, 2, 1, 1)
self.cam_Checkbox = QtWidgets.QCheckBox(Form)
self.cam_Checkbox.setObjectName("cam_Checkbox")
self.gridLayout.addWidget(self.cam_Checkbox, 4, 0, 1, 1)
self.jufeng_Checkbox = QtWidgets.QCheckBox(Form)
self.jufeng_Checkbox.setObjectName("jufeng_Checkbox")
self.gridLayout.addWidget(self.jufeng_Checkbox, 1, 2, 1, 1)
self.scrollArea = QtWidgets.QScrollArea(Form)
self.scrollArea.setMinimumSize(QtCore.QSize(300, 340))
self.scrollArea.setWidgetResizable(True)
self.scrollArea.setObjectName("scrollArea")
self.scrollAreaWidgetContents = QtWidgets.QWidget()
self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, -412, 396, 860))
self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
self.gridLayout_2 = QtWidgets.QGridLayout(self.scrollAreaWidgetContents)
self.gridLayout_2.setObjectName("gridLayout_2")
self.line = QtWidgets.QFrame(self.scrollAreaWidgetContents)
self.line.setFrameShape(QtWidgets.QFrame.HLine)
self.line.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line.setObjectName("line")
self.gridLayout_2.addWidget(self.line, 12, 0, 1, 4)
self.mediapath_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.mediapath_checkBox.setObjectName("mediapath_checkBox")
self.gridLayout_2.addWidget(self.mediapath_checkBox, 34, 0, 1, 1)
self.ivs_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.ivs_Checkbox.setObjectName("ivs_Checkbox")
self.gridLayout_2.addWidget(self.ivs_Checkbox, 17, 0, 1, 1)
self.audioDetect_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.audioDetect_Checkbox.setObjectName("audioDetect_Checkbox")
self.gridLayout_2.addWidget(self.audioDetect_Checkbox, 16, 0, 1, 1)
self.line_3 = QtWidgets.QFrame(self.scrollAreaWidgetContents)
self.line_3.setFrameShape(QtWidgets.QFrame.HLine)
self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_3.setObjectName("line_3")
self.gridLayout_2.addWidget(self.line_3, 37, 0, 1, 4)
self.motionDetect_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.motionDetect_Checkbox.setObjectName("motionDetect_Checkbox")
self.gridLayout_2.addWidget(self.motionDetect_Checkbox, 15, 0, 1, 1)
self.line_4 = QtWidgets.QFrame(self.scrollAreaWidgetContents)
self.line_4.setFrameShape(QtWidgets.QFrame.HLine)
self.line_4.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_4.setObjectName("line_4")
self.gridLayout_2.addWidget(self.line_4, 25, 0, 1, 4)
self.mainMenu_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.mainMenu_Checkbox.setObjectName("mainMenu_Checkbox")
self.gridLayout_2.addWidget(self.mainMenu_Checkbox, 3, 0, 1, 1)
self.usersajustes_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.usersajustes_checkBox.setObjectName("usersajustes_checkBox")
self.gridLayout_2.addWidget(self.usersajustes_checkBox, 28, 0, 1, 1)
self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label.setFont(font)
self.label.setObjectName("label")
self.gridLayout_2.addWidget(self.label, 13, 0, 1, 1)
self.overlap_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.overlap_Checkbox.setObjectName("overlap_Checkbox")
self.gridLayout_2.addWidget(self.overlap_Checkbox, 21, 0, 1, 1)
self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
font = QtGui.QFont()
font.setFamily("MS Shell Dlg 2")
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_2.setFont(font)
self.label_2.setObjectName("label_2")
self.gridLayout_2.addWidget(self.label_2, 6, 0, 1, 1)
self.pushButton_3 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_3.setObjectName("pushButton_3")
self.gridLayout_2.addWidget(self.pushButton_3, 1, 3, 1, 1)
self.backup_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.backup_checkBox.setObjectName("backup_checkBox")
self.gridLayout_2.addWidget(self.backup_checkBox, 30, 0, 1, 1)
self.pushButton_4 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_4.setObjectName("pushButton_4")
self.gridLayout_2.addWidget(self.pushButton_4, 2, 3, 1, 1)
self.abnormalities_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.abnormalities_Checkbox.setObjectName("abnormalities_Checkbox")
self.gridLayout_2.addWidget(self.abnormalities_Checkbox, 20, 0, 1, 1)
self.pushButton_5 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_5.setObjectName("pushButton_5")
self.gridLayout_2.addWidget(self.pushButton_5, 3, 3, 1, 1)
self.tabInfo_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.tabInfo_Checkbox.setObjectName("tabInfo_Checkbox")
self.gridLayout_2.addWidget(self.tabInfo_Checkbox, 7, 0, 1, 1)
self.sceneChange_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.sceneChange_Checkbox.setObjectName("sceneChange_Checkbox")
self.gridLayout_2.addWidget(self.sceneChange_Checkbox, 22, 0, 1, 1)
self.schedule_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.schedule_checkBox.setObjectName("schedule_checkBox")
self.gridLayout_2.addWidget(self.schedule_checkBox, 31, 0, 1, 1)
self.alarmInfo_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.alarmInfo_Checkbox.setObjectName("alarmInfo_Checkbox")
self.gridLayout_2.addWidget(self.alarmInfo_Checkbox, 11, 0, 1, 1)
self.default_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.default_checkBox.setObjectName("default_checkBox")
self.gridLayout_2.addWidget(self.default_checkBox, 29, 0, 1, 1)
self.registers_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.registers_Checkbox.setObjectName("registers_Checkbox")
self.gridLayout_2.addWidget(self.registers_Checkbox, 9, 0, 1, 1)
self.configMenu_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.configMenu_checkBox.setObjectName("configMenu_checkBox")
self.gridLayout_2.addWidget(self.configMenu_checkBox, 4, 0, 1, 1)
self.alarmEvent_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.alarmEvent_Checkbox.setObjectName("alarmEvent_Checkbox")
self.gridLayout_2.addWidget(self.alarmEvent_Checkbox, 19, 0, 1, 1)
self.destination_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.destination_checkBox.setObjectName("destination_checkBox")
self.gridLayout_2.addWidget(self.destination_checkBox, 32, 0, 1, 1)
self.line_2 = QtWidgets.QFrame(self.scrollAreaWidgetContents)
self.line_2.setFrameShape(QtWidgets.QFrame.HLine)
self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken)
self.line_2.setObjectName("line_2")
self.gridLayout_2.addWidget(self.line_2, 5, 0, 1, 4)
self.label_5 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
font = QtGui.QFont()
font.setPointSize(10)
font.setBold(True)
font.setWeight(75)
self.label_5.setFont(font)
self.label_5.setObjectName("label_5")
self.gridLayout_2.addWidget(self.label_5, 26, 0, 1, 1)
self.checkFwVersion_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.checkFwVersion_Checkbox.setObjectName("checkFwVersion_Checkbox")
self.gridLayout_2.addWidget(self.checkFwVersion_Checkbox, 8, 0, 1, 1)
self.login_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.login_Checkbox.setObjectName("login_Checkbox")
self.gridLayout_2.addWidget(self.login_Checkbox, 1, 0, 1, 1)
self.init_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.init_Checkbox.setObjectName("init_Checkbox")
self.gridLayout_2.addWidget(self.init_Checkbox, 0, 0, 1, 1)
self.recPsd_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.recPsd_Checkbox.setObjectName("recPsd_Checkbox")
self.gridLayout_2.addWidget(self.recPsd_Checkbox, 2, 0, 1, 1)
spacerItem4 = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
self.gridLayout_2.addItem(spacerItem4, 24, 0, 1, 1)
spacerItem5 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
self.gridLayout_2.addItem(spacerItem5, 0, 2, 1, 1)
self.tabEvents_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.tabEvents_Checkbox.setObjectName("tabEvents_Checkbox")
self.gridLayout_2.addWidget(self.tabEvents_Checkbox, 14, 0, 1, 1)
self.recordcontrol_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.recordcontrol_checkBox.setObjectName("recordcontrol_checkBox")
self.gridLayout_2.addWidget(self.recordcontrol_checkBox, 35, 0, 1, 1)
self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents)
self.pushButton_2.setCheckable(False)
self.pushButton_2.setObjectName("pushButton_2")
self.gridLayout_2.addWidget(self.pushButton_2, 0, 3, 1, 1)
self.userLogged_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.userLogged_Checkbox.setObjectName("userLogged_Checkbox")
self.gridLayout_2.addWidget(self.userLogged_Checkbox, 10, 0, 1, 1)
self.audio_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.audio_checkBox.setObjectName("audio_checkBox")
self.gridLayout_2.addWidget(self.audio_checkBox, 36, 0, 1, 1)
self.roi_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.roi_Checkbox.setObjectName("roi_Checkbox")
self.gridLayout_2.addWidget(self.roi_Checkbox, 23, 0, 1, 1)
self.upgrade_checkBox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.upgrade_checkBox.setObjectName("upgrade_checkBox")
self.gridLayout_2.addWidget(self.upgrade_checkBox, 33, 0, 1, 1)
self.checkBox_3 = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.checkBox_3.setObjectName("checkBox_3")
self.gridLayout_2.addWidget(self.checkBox_3, 18, 0, 1, 1)
self.tabAjustes_Checkbox = QtWidgets.QCheckBox(self.scrollAreaWidgetContents)
self.tabAjustes_Checkbox.setObjectName("tabAjustes_Checkbox")
self.gridLayout_2.addWidget(self.tabAjustes_Checkbox, 27, 0, 1, 1)
self.init_Checkbox.raise_()
self.pushButton_2.raise_()
self.login_Checkbox.raise_()
self.pushButton_3.raise_()
self.pushButton_4.raise_()
self.recPsd_Checkbox.raise_()
self.mainMenu_Checkbox.raise_()
self.pushButton_5.raise_()
self.configMenu_checkBox.raise_()
self.tabInfo_Checkbox.raise_()
self.checkFwVersion_Checkbox.raise_()
self.registers_Checkbox.raise_()
self.userLogged_Checkbox.raise_()
self.alarmInfo_Checkbox.raise_()
self.tabEvents_Checkbox.raise_()
self.motionDetect_Checkbox.raise_()
self.audioDetect_Checkbox.raise_()
self.ivs_Checkbox.raise_()
self.checkBox_3.raise_()
self.alarmEvent_Checkbox.raise_()
self.overlap_Checkbox.raise_()
self.abnormalities_Checkbox.raise_()
self.sceneChange_Checkbox.raise_()
self.roi_Checkbox.raise_()
self.label.raise_()
self.line.raise_()
self.line_2.raise_()
self.label_2.raise_()
self.line_3.raise_()
self.usersajustes_checkBox.raise_()
self.default_checkBox.raise_()
self.destination_checkBox.raise_()
self.schedule_checkBox.raise_()
self.backup_checkBox.raise_()
self.audio_checkBox.raise_()
self.recordcontrol_checkBox.raise_()
self.mediapath_checkBox.raise_()
self.upgrade_checkBox.raise_()
self.line_4.raise_()
self.label_5.raise_()
self.tabAjustes_Checkbox.raise_()
self.scrollArea.setWidget(self.scrollAreaWidgetContents)
self.gridLayout.addWidget(self.scrollArea, 10, 0, 1, 4)
self.retranslateUi(Form)
QtCore.QMetaObject.connectSlotsByName(Form)
def retranslateUi(self, Form):
_translate = QtCore.QCoreApplication.translate
Form.setWindowTitle(_translate("Form", "Form"))
self.dahua_Checkbox.setText(_translate("Form", "Dahua"))
self.startTest_Btn.setText(_translate("Form", "Iniciar teste"))
self.label_3.setText(_translate("Form", "IP"))
self.label_4.setText(_translate("Form", "Porta"))
self.nvr_Checkbox.setText(_translate("Form", "NVR"))
self.supplier_Label.setText(_translate("Form", "Fornecedor"))
self.device_Label.setText(_translate("Form", "Dispositivo"))
self.cam_Checkbox.setText(_translate("Form", "Câmera"))
self.jufeng_Checkbox.setText(_translate("Form", "Jufeng"))
self.mediapath_checkBox.setText(_translate("Form", "Destino de Midia"))
self.ivs_Checkbox.setText(_translate("Form", "Análise de vídeo"))
self.audioDetect_Checkbox.setText(_translate("Form", "Detecção de áudio"))
self.motionDetect_Checkbox.setText(_translate("Form", "Detecção Movimento"))
self.mainMenu_Checkbox.setText(_translate("Form", "Tela Principal"))
self.usersajustes_checkBox.setText(_translate("Form", "Usuários"))
self.label.setText(_translate("Form", "Eventos"))
self.overlap_Checkbox.setText(_translate("Form", "Máscara de vídeo"))
self.label_2.setText(_translate("Form", "Informações"))
self.pushButton_3.setText(_translate("Form", "Alterar"))
self.backup_checkBox.setText(_translate("Form", "Backup"))
self.pushButton_4.setText(_translate("Form", "Alterar"))
self.abnormalities_Checkbox.setText(_translate("Form", "Anormalidade"))
self.pushButton_5.setText(_translate("Form", "Alterar"))
self.tabInfo_Checkbox.setText(_translate("Form", "Aba Info"))
self.sceneChange_Checkbox.setText(_translate("Form", "Mudança de Cena"))
self.schedule_checkBox.setText(_translate("Form", "Agendamento"))
self.alarmInfo_Checkbox.setText(_translate("Form", "Alarme - Info"))
self.default_checkBox.setText(_translate("Form", "Padrão"))
self.registers_Checkbox.setText(_translate("Form", "Registros"))
self.configMenu_checkBox.setText(_translate("Form", "Menu Configurações"))
self.alarmEvent_Checkbox.setText(_translate("Form", "Alarme - Eventos"))
self.destination_checkBox.setText(_translate("Form", "Local"))
self.label_5.setText(_translate("Form", "Usuários"))
self.checkFwVersion_Checkbox.setText(_translate("Form", "Confere Versão"))
self.login_Checkbox.setText(_translate("Form", "Login"))
self.init_Checkbox.setText(_translate("Form", "Inicialização"))
self.recPsd_Checkbox.setText(_translate("Form", "Recuperação de senha"))
self.tabEvents_Checkbox.setText(_translate("Form", "Aba Eventos"))
self.recordcontrol_checkBox.setText(_translate("Form", "Gravação"))
self.pushButton_2.setText(_translate("Form", "Alterar"))
self.userLogged_Checkbox.setText(_translate("Form", "Usuários Logados"))
self.audio_checkBox.setText(_translate("Form", "Áudio"))
self.roi_Checkbox.setText(_translate("Form", "Área de interesse"))
self.upgrade_checkBox.setText(_translate("Form", "Atualização"))
self.checkBox_3.setText(_translate("Form", "Detecção de Face"))
self.tabAjustes_Checkbox.setText(_translate("Form", "Aba Ajustes"))
if __name__ == "__main__":
import sys
app = QtWidgets.QApplication(sys.argv)
MainWindow = QtWidgets.QMainWindow()
ui = Ui_MainWindow()
ui.setupUi(MainWindow)
MainWindow.show()
sys.exit(app.exec_())
我的GUI就是这样:
这应该是这样的: Right GUI
请帮助我解决这个问题。