您好,我是使用qt进行python编程的新手,但是现在我有一个疑问,因为我创建了一个包含菜单栏的窗口并且它可以工作,但是菜单栏的响应非常慢,因为它没有立即单击两次就响应我。我该如何解决
from PyQt5 import QtCore, QtGui, QtWidgets
import sys,os
import time as tim
import xlsxwriter#se encarga de Excel
import xmltodict #se encarga de XML
class MyWindow(object):
form=['UUID','Monto Asociado','Tipo de Factura']
direc=[]
data_xml=[]
Save=[]
control=0
control2=0
def setupUi(self, Dialog):
Dialog.setObjectName("Dialog")
Dialog.setFixedSize(400, 700)
Dialog.setMouseTracking(False)
Dialog.setAcceptDrops(False)
Dialog.setAutoFillBackground(False)
QtWidgets.QApplication.setWindowIcon(QtGui.QIcon('icon.gif'))
self.heren=Dialog
extractActionfiles = QtWidgets.QAction("&Go to Exit", Dialog)
extractActionfiles.setShortcut("Ctrl+Q")
extractActionfiles.setStatusTip('Leave The App')
extractActionfiles.triggered.connect(QtWidgets.qApp.quit)
extractActionfiles_2 = QtWidgets.QAction("&Reset", Dialog)
extractActionfiles_2.setStatusTip('Reset the Variables')
extractActionfiles_2.setShortcut("Ctrl+N")
extractActionfiles.triggered.connect(self.reseteo)
#extractActiontools = QtWidgets.QAction("&sin desarroyar", Dialog)
#extractActiontools.setShortcut("Ctrl+N")
#extractActiontools.setStatusTip('Control the app')
menubar=QtWidgets.QMainWindow.menuBar(Dialog)
fileMenu = menubar.addMenu('&File')
fileMenu.addAction(extractActionfiles)
#fileMenu.addAction(extractActionfiles_2)
#toolsMenu = menubar.addMenu('&Tools')
#toolsMenu.addAction(extractActiontools)
self.pushButton = QtWidgets.QPushButton(Dialog)#xml
self.pushButton.setGeometry(QtCore.QRect(60, 30, 120, 40))
self.pushButton.setObjectName("pushButton")
self.pushButton.clicked.connect(self.lector_xml)
self.lineEdit = QtWidgets.QTextEdit(Dialog)
self.lineEdit.setGeometry(QtCore.QRect(20, 90, 300, 50))
self.lineEdit.setObjectName("lineEdit")
self.lineEdit.setEnabled(True)
self.progressBar_2 = QtWidgets.QProgressBar(Dialog)#xml
self.progressBar_2.setGeometry(QtCore.QRect(20, 147, 381, 31))
self.progressBar_2.setProperty("value", 0)
self.progressBar_2.setObjectName("progressBar")
self.label_2 = QtWidgets.QLabel(Dialog)#xml
self.label_2.setGeometry(QtCore.QRect(20, 70, 65, 20))
self.label_2.setObjectName("label_2")
self.pushButton_2 = QtWidgets.QPushButton(Dialog)#metadata
self.pushButton_2.setGeometry(QtCore.QRect(60, 190, 120, 40))
self.pushButton_2.setObjectName("pushButton_2")
self.pushButton_2.clicked.connect(self.lector_uuid_metadata)
self.lineEdit_2 = QtWidgets.QTextEdit(Dialog)#metadata
self.lineEdit_2.setGeometry(QtCore.QRect(20, 255,300, 50))
self.lineEdit_2.setObjectName("lineEdit_2")
self.lineEdit_2.setEnabled(True)
self.progressBar = QtWidgets.QProgressBar(Dialog)#metadata
self.progressBar.setGeometry(QtCore.QRect(20, 315, 381, 31))
self.progressBar.setProperty("value", 0)
self.progressBar.setObjectName("progressBar")
self.label_3 = QtWidgets.QLabel(Dialog)#metadata
self.label_3.setGeometry(QtCore.QRect(20, 230, 140, 16))
self.label_3.setObjectName("label_3")
#self.scrollArea3 = QtWidgets.QScrollArea(Dialog)
#self.scrollArea3.setGeometry(QtCore.QRect(0, 508, 1036, 300))
#self.scrollArea3.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
#self.scrollArea3.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOn)
#self.scrollArea3.setWidgetResizable(True)
#self.scrollArea3.setObjectName("scrollArea")
#self.scrollArea3.setEnabled(True)
self.lineEdit_3 = QtWidgets.QTextEdit(Dialog)#datavalidation
self.lineEdit_3.setGeometry(QtCore.QRect(0, 508, 400, 192))
self.lineEdit_3.setMouseTracking(False)
self.lineEdit_3.setObjectName("lineEdit_3")
self.lineEdit_3.setEnabled(False)
self.label = QtWidgets.QLabel(Dialog)#datavalidation
self.label.setGeometry(QtCore.QRect(20, 485, 161, 20))
self.label.setTabletTracking(True)
self.label.setObjectName("label")
self.pushButton_3 = QtWidgets.QPushButton(Dialog)
self.pushButton_3.setGeometry(QtCore.QRect(20, 390, 120, 40))
self.pushButton_3.setObjectName("pushButton_3")
self.pushButton_3.clicked.connect(self.accept)
self.pushButton_3.setEnabled(False)
self.progressBar_3 = QtWidgets.QProgressBar(Dialog)#xml
self.progressBar_3.setGeometry(QtCore.QRect(20, 450, 381, 31))
self.progressBar_3.setProperty("value", 0)
self.progressBar_3.setObjectName("progressBar")
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
def retranslateUi(self, Dialog):
_translate = QtCore.QCoreApplication.translate
Dialog.setWindowTitle(_translate("Dialog", "interfase xml by metadata "))
self.pushButton.setText(_translate("Dialog", "xml"))
self.pushButton_2.setText(_translate("Dialog", "metadata"))
self.label.setText(_translate("Dialog", "data validation :"))
self.label_2.setText(_translate("Dialog", "xml data:"))
self.label_3.setText(_translate("Dialog", "metadata content:"))
self.pushButton_3.setText(_translate("Dialog", "Start validation"))
def Principal():
app =QtWidgets.QApplication([])
window =QtWidgets.QMainWindow()
main_window=MyWindow()
main_window.setupUi(window)
window.show()
app.exec_()
sys.exit(app.exec())
Principal()
我正在使用功能快捷键,并且在第二次单击时没有立即响应