I created a login interface in Qt Designer and when I converted it to Python code and ran it, everything looked just fine up until I clicked the log-in button and that was when the program just ended without running the function that I created which was supposed to pop up a message box when the user either correctly inputs a validated email and password or if they incorrectly input one as well. This is the code that I currently have: import sys import re from PyQt5 import QtWidgets from PyQt5.QtWidgets import QMessageBox, QApplication, QMainWindow, QLineEdit from PyQt5.uic import loadUi class Login(QMainWindow): def __init__(self): super(Login, self).__init__() loadUi("login2.ui", self) self.loginbutton.clicked.connect(self.loginfunction) # Cover the password input self.passwordentry.setEchoMode(QLineEdit.Password) def loginfunction(self): email = self.email.text() password = self.passwordentry.text() if not self.validate_email(email): QMessageBox.warning(self, "Invalid Email", "Please enter a valid email address.") return if not self.validate_password(password): QMessageBox.warning(self, "Invalid Password", "Password must meet the following requirements:\n" "- Minimum 8 characters\n" "- At least one lowercase letter\n" "- At least one uppercase letter\n" "- At least one digit\n" "- At least one special character (_@$).") return QMessageBox.information(self, "Login Success", "You have successfully logged in!") @staticmethod def validate_email(email): pattern = r'^[a-zA-Z0-9_-]+@[a-zA-Z0-9]+\.[a-zA-Z]{1,3}$' return re.fullmatch(pattern, email) is not None @staticmethod def validate_password(password): if len(password) < 8: return False if not any(char.islower() for char in password): return False if not any(char.isupper() for char in password): return False if not any(char.isdigit() for char in password): return False if not any(char in "_@$" for char in password): return False return True app = QApplication(sys.argv) mainwindow = Login() mainwindow.show() widget = QtWidgets.QStackedWidget() widget.addWidget(mainwindow) widget.setFixedWidth(600) widget.setFixedHeight(800) widget.show() app.exec_() This is what the program looks like: A screenshot of the properties for the login button in Qt Designer: Continue reading...