示例#1
0
class App(QMainWindow):
    def __init__(self, parent=None, width=0, height=0):
        super(App, self).__init__(parent)
        self.home = Home()
        self.resize(width, height)
        # self.showMaximized()
        self.home.setupUi(self)
        try:
            self.auth = Auth(self.home, self)
        except TypeError:
            settings = QSettings()
            settings.clear()
            QMessageBox.warning(
                parent, "Error",
                "Your Application Data is Corrupted, Restart the application")
            sys.exit()
        self.home.manLecturerBtn.clicked.connect(self.manLecturePage)
        self.home.manCoursesBtn.clicked.connect(self.manCoursePage)
        self.home.manLectHallBtn.clicked.connect(self.manLectHallPage)
        self.home.manClassRepsBtn.clicked.connect(self.manClassRepPage)
        self.home.courseGrading.clicked.connect(self.viewGradingPage)
        self.home.getGrading.clicked.connect(self.getRecentGrades)
        self.home.chngResource.clicked.connect(self.getCumulatedGrades)
        self.home.levelCombo.currentIndexChanged.connect(self.loadLecturers)
        self.home.lecturerCombo.currentIndexChanged.connect(
            self.loadCourseList)
        self.home.cr_level.currentIndexChanged.connect(self.loadcr)
        self.home.cr_list.itemDoubleClicked.connect(self.update_cr)
        self.home.lectList.itemDoubleClicked.connect(self.update_lect)
        self.home.aboutButton.clicked.connect(self.dispAbout)
        self.home.settingBtn.clicked.connect(self.settingsPage)

    def manLecturePage(self):
        self.home.setActiveButton(self.home.manLecturerBtn)
        self.home.stackedWidget.setCurrentIndex(4)
        self.auth.manLecturers(f='init')
        self.home.addLecturer.clicked.connect(self.auth.manLecturers)

    def manLectHallPage(self):
        self.home.setActiveButton(self.home.manLectHallBtn)
        self.home.stackedWidget.setCurrentIndex(2)
        self.auth.loadLectHall()
        self.home.addVenue.clicked.connect(self.auth.addLectHall)

    def manCoursePage(self):
        self.home.setActiveButton(self.home.manCoursesBtn)
        self.home.stackedWidget.setCurrentIndex(3)
        self.auth.loadCourse()
        self.home.addCourseBtn.clicked.connect(self.auth.addCourse)

    def manClassRepPage(self):
        self.home.setActiveButton(self.home.manClassRepsBtn)
        self.home.stackedWidget.setCurrentIndex(5)
        self.auth.loadcr()
        self.home.addcrBtn.clicked.connect(self.auth.addcr)

    def viewGradingPage(self):
        self.home.setActiveButton(self.home.courseGrading)
        self.home.stackedWidget.setCurrentIndex(1)

    def settingsPage(self):
        self.home.setActiveButton(self.home.settingBtn)
        self.home.stackedWidget.setCurrentIndex(6)

    def loadCourseList(self):
        self.auth.loadCourseList()

    def loadLecturers(self):
        self.auth.loadLecturers()

    def loadcr(self):
        self.auth.loadcr(l='input')

    def getRecentGrades(self):
        self.auth.getGrades(t="r")

    def getCumulatedGrades(self):
        self.auth.getGrades(t="c")

    def addLecturers(self):
        self.auth.addLecturers()

    def update_cr(self):
        self.auth.update_cr()

    def update_lect(self):
        index = self.home.lectList.currentRow()
        modLect = Mod_Lecturer(self.auth.lect[index], self.auth.courses, self)
        # mod_cr = modClassRep.Mod_cr()
        modLect.exec_()
        self.close()
        self.auth.update_lect()

    def update_course(self):
        modCourse = modCourse.Mod_Course()

    def dispAbout(self):
        x = About()
        x.exec_()