I'm currently creating a sort of student appointment system where students can set appointments to their respective instructors. Currently, I've made 3 widgets named main.py for the login, admin.py, and faculty.py, converted from the ui files that I've made.

My goal for the meantime is have the user go to the admin widget if they logged with an admin acct and otherwise, faculty widget.

Here's my attempt so far:

main.py (QDialog)

from PyQt5 import QtCore, QtGui, QtWidgets
from admin import Ui_MainWindow
from faculty import Ui_MainWindow


class Ui_Login(object):
    def loginbtn(self):
        usernm = self.user_id.text()
        psswrd = self.password.text()

        if usernm == "admin" and psswrd == "admin123":
            self.openadmin()
        elif usernm == "12345" and psswrd == "12345":
            self.openfaculty()

    def openadmin(self):
        self.window = QtWidgets.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui.setupUi(self.window)
        self.window.show()

    def openfaculty(self):
        self.window = QtWidgets.QMainWindow()
        self.ui = Ui_MainWindow()
        self.ui = setupUi(self.window)
        self.window.show()

    def setupUi(self, Login):
        -contains the widget parts-
        self.loginbutton.clicked.connect(self.loginbtn)
    
    def retranslateUi(self, Login):

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    login = QtWidgets.QDialog()
    ui = Ui_Login()
    ui.setupUi(login)
    login.show()
    sys.exit(app.exec_())

admin.py (QMainWindow)(not functional at the moment)

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):

    def retranslateUi(self, MainWindow):

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    faculty = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(faculty)
    faculty.show()
    sys.exit(app.exec_())

faculty.py (QMainWindow)(also not functional at the moment)

from PyQt5 import QtCore, QtGui, QtWidgets


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):

    def retranslateUi(self, MainWindow):

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    admin = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(admin)
    admin.show()
    sys.exit(app.exec_())

What my attempt does is if the loginbutton is pressed, it goes to loginbtn() and checks whether an admin account or that 12345 which serves as a faculty account is used to login and then goes to either openadmin() to load admin.py or openfaculty() for faculty.py. However, when I try to log in using an admin acct, it ends up going to openfaculty() and closes if that 12345 acct is used and returns the following exit code.

Process finished with exit code -1073740791 (0xC0000409)

Also, setupUi inside openfaculty() is unresolved reference for some reason.

0

There are 0 best solutions below