time error when I'm trying to close the app. Here's the code. I'm using pyqt5 designer.
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import QDialog, QApplication, QMessageBox, QGridLayout
from PyQt5 import QtCore, QtGui, QtWidgets
class Ui_Dialog(object):
def setupUi(self, Dialog):
#Form Dialog
grid = QGridLayout()
Dialog.setLayout(grid)
Dialog.setObjectName("LoginForm")
Dialog.resize(640, 480)
#Button Exit
self.btnEsc = QtWidgets.QPushButton(Dialog)
I'm having trouble on this part of the code "(self.closeEvent)"
self.btnEsc.clicked.connect(self.closeEvent)
self.btnEsc.setGeometry(QtCore.QRect(380, 310, 75, 61))
self.btnEsc.setObjectName("btnEsc")
#Form translate
self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)
when I close this part(running), it pops up a message "Python has stopped working"
def closeEvent(self, event):
reply = QMessageBox.question(self, 'Message',
"Are you sure to quit?",
QMessageBox.Yes | QMessageBox.No, QMessageBox.No)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
I just want a customized for exit button, please help....