I am making a simple GUI in python using pyqt5. I am finally able to open the mainGUI window using QMainWindow by assigning the reference to self.win. Also, I want to be able to display the error message if the login is incorrect. However, the error window isn't showing up and exits with an exit code -1073740791 (0xC0000409)
Here is the snippet of my code.
main.py
import sys
from PyQt5.QtWidgets import QApplication, QMainWindow
import gui.loginGUI, gui.mainGUI, gui.errorGUI
import db.connect
class mainApp(QMainWindow):
def __init__(self):
self.app_Login = gui.loginGUI.login()
self.app_Login.loginB.clicked.connect(
lambda: self.loginCredentials(self.app_Login.username.text(), self.app_Login.pwd.text())
)
def loginCredentials(self, username, pwd):
# check for login credentials
if db.connect.connect(username, pwd).checkConn() != 0:
self.app_Login.close()
self.win = gui.mainGUI.Window(username, pwd)
else:
gui.errorGui.ErrorGUI("Wrong Credentials")
self.app_Login.username.clear()
self.app_Login.pwd.clear()
if __name__ == "__main__":
try:
app = QApplication(sys.argv)
mainApp()
app.exec_()
except Exception as e:
print(e)
errorGUI.py
from PyQt5.QtWidgets import QWidget, QMessageBox
from PyQt5.QtGui import QIcon
class Error(QWidget):
def __init__(self, message):
super().__init__()
alert = QMessageBox()
alert.setText(message)
alert.setWindowTitle("Error")
alert.exec_()
User contributions licensed under CC BY-SA 3.0