Esempio n. 1
0
    def cgcalc(self):

        cur.execute("select * from grades")
        a = cur.fetchone()

        if a == None:
            self.showmessage('Set default grading system first')

            self.gradingsystem = Startgrade()
            self.gradingsystem.show()
            QtCore.QObject.connect(self.gradingsystem.ui.done,
                                   QtCore.SIGNAL("clicked()"), self.cgcalc)

        else:
            cur.execute("select * from acads")
            a = cur.fetchone()

            if a == None:
                self.showmessage('Add a subject first')
            else:

                self.cgcalc2 = Startcgcalc()
                self.ui.maintabWidget.insertTab(4, self.cgcalc2, 'Grades')
                self.cgflag = 1
                cur.execute("insert into cgflag values(1)")
                con.commit()
Esempio n. 2
0
    def cgcalc(self):
        
        cur.execute("select * from grades")
        a = cur.fetchone()

        
        if a==None:
            self.showmessage('Set default grading system first')

            self.gradingsystem = Startgrade()
            self.gradingsystem.show()
            QtCore.QObject.connect(self.gradingsystem.ui.done, QtCore.SIGNAL("clicked()"), self.cgcalc)
            
        else:
            cur.execute("select * from acads")
            a = cur.fetchone()
            
            if a==None:
                self.showmessage('Add a subject first')
            else:

                self.cgcalc2 = Startcgcalc()
                self.ui.maintabWidget.insertTab(4, self.cgcalc2, 'Grades')
                self.cgflag = 1
                cur.execute("insert into cgflag values(1)")
                con.commit()
Esempio n. 3
0
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_window()
        self.ui.setupUi(self)
        self.editgrades = Startgrade()
        

        self.setsem()
        self.ui.sem.setVisible(False)
        self.sub = (self.ui.sub1, self.ui.sub2, self.ui.sub3, self.ui.sub4, self.ui.sub5, self.ui.sub6, self.ui.sub7, self.ui.sub8, self.ui.sub9, self.ui.sub10, )
        
        self.credit = (self.ui.credit1, self.ui.credit2, self.ui.credit3, self.ui.credit4, self.ui.credit5, self.ui.credit6, self.ui.credit7, self.ui.credit8, self.ui.credit9, self.ui.credit10, )

        self.grade = (self.ui.grade1, self.ui.grade2, self.ui.grade3, self.ui.grade4, self.ui.grade5, self.ui.grade6, self.ui.grade7, self.ui.grade8, self.ui.grade9, self.ui.grade10, ) 
        
        self.gradeinvisible()
        self.clear()
        self.setgrade1()
        self.setsub()

        self.setnumeqdict()
        self.setgrade2()
        
        for i in range(0, 10):
            self.grade[i].setStyleSheet('selection-background-color: rgb(85, 85, 255); selection-color: rgb(255, 255, 255)')            
        
        QtCore.QObject.connect(self.ui.sem, QtCore.SIGNAL("currentIndexChanged(int)"), self.setsub)
        QtCore.QObject.connect(self.ui.cgpa_button, QtCore.SIGNAL("clicked()"), self.calc_cgpa)
        QtCore.QObject.connect(self.ui.gpa_button, QtCore.SIGNAL("clicked()"), self.calc_gpa)
        QtCore.QObject.connect(self.ui.editgrades, QtCore.SIGNAL("clicked()"), self.editgradesed)
        QtCore.QObject.connect(self.ui.save, QtCore.SIGNAL("clicked()"), self.saved)

        self.ui.cgpa_button.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')
        self.ui.gpa_button.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')
        self.ui.editgrades.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')        
        self.ui.save.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')        
Esempio n. 4
0
class Startmain(QtGui.QMainWindow):

    
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_window2()
        self.ui.setupUi(self)
        self.setWindowTitle('acadmin - Academic Management Tool')

        icon = QtGui.QIcon()
        b = QtGui.QPixmap("./pics/logo.png")
        icon.addPixmap(b)

        self.setWindowIcon(icon)

        
        self.setFixedWidth(931)
        self.setFixedHeight(668)
        
        b = QtGui.QPixmap("./pics/hide.png")
        self.ui.hide.setPixmap(QtGui.QPixmap(b))
        
        self.subtabWidget = QtGui.QTabWidget()
        
        self.dummybutton2 = QtGui.QToolButton()

        self.setdate()
        self.setsem()
        self.setallwidgets()
        self.setsub()
        self.setmaintabwidget()
        self.checkdb()
        
        self.setpics()
        self.settoolbar()

        self.setstickynote()

        self.editsub = Starteditsub()

        QtCore.QObject.connect(self.ui.maintabWidget, QtCore.SIGNAL("currentChanged(int)"), self.timetabletab)     
        QtCore.QObject.connect(self.editsub.ui.change, QtCore.SIGNAL("clicked()"), self.setsub)        
        QtCore.QObject.connect(self.ui.cgcalc, QtCore.SIGNAL("clicked()"), self.showcg)
        QtCore.QObject.connect(self.ui.calendar, QtCore.SIGNAL("clicked()"), self.showcalendar)
        QtCore.QObject.connect(self.ui.home, QtCore.SIGNAL("clicked()"), self.showhome)
        QtCore.QObject.connect(self.ui.timetable, QtCore.SIGNAL("clicked()"), self.showtimetable)
        QtCore.QObject.connect(self.ui.editsem, QtCore.SIGNAL("clicked()"), self.showeditsem)
        QtCore.QObject.connect(self.ui.defsem, QtCore.SIGNAL("clicked()"), self.defaultsem)
        QtCore.QObject.connect(self.ui.about, QtCore.SIGNAL("clicked()"), self.showabout)
        QtCore.QObject.connect(self.ui.help, QtCore.SIGNAL("clicked()"), self.showhelp)
        
        self.clickflag = 0
        self.clickflag2 = 0
        self.ttflag = 0
        self.cgflag = 0
        
    def showhelp(self):
        self.help = Starthelp()
        self.help.show()
    def checkdb(self):
        cur.execute("select * from acads")
        a = cur.fetchone()
        
        if a==None:
	    self.ui.maintabWidget.setCurrentIndex(1)
            message = QtGui.QMessageBox(self)
            message.setText('Welcome to "acadmin". Start by adding a subject.')
            message.setWindowTitle('Acadmin alert')
            message.setIcon(QtGui.QMessageBox.Information)
            message.exec_()
	    
	
    def showabout(self):
        self.showabt = Startabout()
        self.showabt.show()
        
    def showcalendar(self):
        self.ui.maintabWidget.setCurrentIndex(2)

    def showhome(self):
        self.ui.maintabWidget.setCurrentIndex(0)

    def showeditsem(self):
        self.ui.maintabWidget.setCurrentIndex(1)

    def showtimetable(self):
        self.ui.maintabWidget.setCurrentIndex(3)
        if self.clickflag!=1:
            self.clickflag = 1
            self.ui.timetable.click()
                
    def showcg(self):
        self.ui.maintabWidget.setCurrentIndex(4)
        if self.clickflag2!=1:
            self.clickflag2 = 1
            self.ui.cgcalc.click()
        
    
    
    def defaultsem(self):
        cur.execute("select * from acads")
        a = cur.fetchone()
        
        if a==None:
            self.showmessage('Add a subject first')
	    self.ui.editsem.click()
        else:
            self.setdefaultsem = Startdefaultsem()
            self.setdefaultsem.show()
            QtCore.QObject.connect(self.setdefaultsem.ui.okay, QtCore.SIGNAL("clicked()"), self.setdefsemandclose)
           
    def setdefsemandclose(self):
        self.setsem()
        self.close()

    def timetabletab(self):
        a = self.ui.maintabWidget.currentIndex()

        b = self.ttflag
        c = self.cgflag        
                
        if a==3:        
            if b==0:
                self.settimetable()
            
            if self.ui.maintabWidget.count()>5:
                self.ui.maintabWidget.removeTab(4)
        
        if a==4:
            if c==0:
                self.cgcalc()
                
            if self.ui.maintabWidget.count()>5:
                self.ui.maintabWidget.removeTab(5)
        
    def setallwidgets(self):
        if self.ui.sem.text()=='':
            sem = None
        else :
            sem = int(self.ui.sem.text())

        self.editsem = Starteditsem()        
        self.calendar = Startcalendar(sem)        

    def setmaintabwidget(self):
        self.notrequired = QtGui.QWidget()
        self.notrequired2 = QtGui.QWidget()
        self.ui.maintabWidget.clear()
        self.ui.maintabWidget.insertTab(0, self.subtabWidget, 'Home')
        self.ui.maintabWidget.insertTab(1, self.editsem, 'Add/Delete Subjects')
        self.editsemsignals()
        self.ui.maintabWidget.insertTab(2, self.calendar, 'Calendar')
        self.calendarsignals()
        self.ui.maintabWidget.insertTab(3, self.notrequired, 'Timetable')
        self.ui.maintabWidget.insertTab(4, self.notrequired2, 'Grades')
        
    def cgcalc(self):
        
        cur.execute("select * from grades")
        a = cur.fetchone()

        
        if a==None:
            self.showmessage('Set default grading system first')

            self.gradingsystem = Startgrade()
            self.gradingsystem.show()
            QtCore.QObject.connect(self.gradingsystem.ui.done, QtCore.SIGNAL("clicked()"), self.cgcalc)
            
        else:
            cur.execute("select * from acads")
            a = cur.fetchone()
            
            if a==None:
                self.showmessage('Add a subject first')
            else:

                self.cgcalc2 = Startcgcalc()
                self.ui.maintabWidget.insertTab(4, self.cgcalc2, 'Grades')
                self.cgflag = 1
                cur.execute("insert into cgflag values(1)")
                con.commit()
        
    def settimetable(self):

        cur.execute("select max(day) from timetable")
        a = cur.fetchone()
        
        
        if a[0]==None:
            cur.execute("select * from days")
            b = cur.fetchone()

            if b==None:
                self.showmessage('Set timeslots and Days first')
                self.ttdetails = Startttdetailsex()
                self.ttdetails.show()
                QtCore.QObject.connect(self.ttdetails.done, QtCore.SIGNAL("clicked()"), self.settimetable)
                QtCore.QObject.connect(self.ttdetails.cancel, QtCore.SIGNAL("clicked()"), self.settimetable)
            
            else:
                cur.execute("select * from acads")
                a = cur.fetchone()
                if a==None:
                    self.showmessage('Add a subject first')
                    
            
                else:
                    self.showmessage('Set the periods and save')
                    self.ttedit = Starttimetableedit()
                    self.ttedit.show()
                    
                    QtCore.QObject.connect(self.ttedit.save, QtCore.SIGNAL("clicked()"), self.settimetable)
        
        else:

            self.timetable = Starttimetable()
            
            self.ui.maintabWidget.insertTab(3, self.timetable, 'Timetable')
            self.ttflag = 1
            cur.execute("insert into timetableflag values(1)")
            con.commit()
                        
    def calendarsignals(self):

        QtCore.QObject.connect(self.calendar.savebunk, QtCore.SIGNAL("clicked()"), self.setsub)
        QtCore.QObject.connect(self.calendar.t.ui.add, QtCore.SIGNAL("clicked()"), self.setstickynote)
        QtCore.QObject.connect(self.calendar.dummybutton, QtCore.SIGNAL("clicked()"), self.setstickynote)
        
    def editsemsignals(self):

        QtCore.QObject.connect(self.editsem.ui.add, QtCore.SIGNAL("clicked()"), self.setsub2)
        QtCore.QObject.connect(self.editsem.ui.delete_2, QtCore.SIGNAL("clicked()"), self.setsub2)

    def setsub(self):
   
        self.subtabWidget.clear()
        self.startframe = []

        if self.ui.sem.text()!='':
            c = (int(self.ui.sem.text()),)
            cur.execute("select * from acads where semester = ?", c)
        
            i=0
            k = 0
        
            subcode = []
            subname = []
            credits = []
            bunksleft = []
            classes = []
            attendance = []
        
            for row in cur:
                subcode.append(row[1])
                subname.append(row[2])
                credits.append(row[3])
                bunksleft.append(row[5]-row[6])
                classes.append(row[7])
                attendance.append(row[8])
                k = k+1
        
            for i in range(0, k):
                self.startframe.append(Startframe(str(subcode[i]), classes[i], attendance[i]))
                a = self.subtabWidget.insertTab(i, self.startframe[i], subcode[i])
                self.startframe[i].subjectname.setText(subname[i])
                self.startframe[i].credits.setText(str(credits[i]))
                self.startframe[i].subjectcode.setText(str(subcode[i]))
                self.startframe[i].bunksleft.setText(str(bunksleft[i]))
                QtCore.QObject.connect(self.startframe[i].editsubject.ui.change, QtCore.SIGNAL("clicked()"), self.setsub3)
                QtCore.QObject.connect(self.startframe[i].addref.ui.add, QtCore.SIGNAL("clicked()"), self.setsub3)
                QtCore.QObject.connect(self.startframe[i].deleteref.ui.deletebutton, QtCore.SIGNAL("clicked()"), self.setsub3)
                i = i+1
        

        self.ui.maintabWidget.removeTab(0)
        self.ui.maintabWidget.insertTab(0, self.subtabWidget, 'Home')

    def setsub3(self):
        self.setsub()
        self.ui.home.click()

    def setsub2(self):
        
        flag = 0
        
        cur.execute("select * from acads")
        
        for row in cur:
        	flag = flag+1
        
        self.setsem()
        self.setsub()
        self.calendar.setbunkclasses()
        self.calendar.setbunkticks()
        self.ui.home.click()
        
        if flag==1:
        	self.ui.defsem.click()
        
    
    def setsem(self):
        cur.execute("select * from defsem")
        a = cur.fetchone()
        
        if a!=None:
            self.ui.sem.setText(str(a[0]))



    def showmessage(self, a):
        message = QtGui.QMessageBox(self)
        message.setText(a)
        message.setWindowTitle('Acadmin alert')
        message.setIcon(QtGui.QMessageBox.Warning)
        message.exec_()

    def setdate(self):

        self.date = datetime.datetime.now()
        self.month = [None, 'Jan.', 'Feb.', 'March', 'April', 'May', 'June', 'July', 'Aug.', 'Sept.', 'Oct.', 'Nov.', 'Dec.', ]
        
        self.ui.day.setText("<span style=\" font-size:48pt; font-weight:600; color:#ffff00;\">"+ str(self.date.day) + "</span>")
        self.ui.monthyear.setText("<span style=\" font-size:12pt; font-weight:600; color:#ffff00;\">"+ self.month[self.date.month] + "  " + str(self.date.year) + "</span>")
        self.ui.day.setAlignment(Qt.AlignHCenter)
        self.ui.monthyear.setAlignment(Qt.AlignHCenter)

    def setstickynote(self):
        
        stickylist=QtGui.QWidget()
        stickylist.setSizePolicy(QtGui.QSizePolicy.Expanding, QtGui.QSizePolicy.Expanding)
        stickylistgrid = QtGui.QGridLayout()

        stickylistgrid.addWidget(QtGui.QLabel("        "), 0, 0)        
        stickylistgrid.addWidget(QtGui.QLabel("<b>.  Today's Tasks :</b>"), 1, 0)
        
        todaytask = []
        i=0
        t = (self.date.day, self.date.month, self.date.year, )
        cur.execute("select * from reminder where day = ? and month = ? and year = ?", t)
        a = cur.fetchone()
        
        
        if a==None:
            stickylistgrid.addWidget(QtGui.QLabel("<i>.    No assignments</i>"), 2, 0)

        else:

            cur.execute("select * from reminder where day = ? and month = ? and year = ?", t)
            for row in cur:
                todaytask.append(QtGui.QLabel('   ' + str(i+1)+'. '+str(row[0])+' - '+str(row[1])))
                stickylistgrid.addWidget(todaytask[i], i+2, 0)
                i = i+1


        stickylistgrid.addWidget(QtGui.QLabel("<b>.  Tomorrow's Tasks :</b>"), i+3, 0)

        today = QtCore.QDate(self.date.year, self.date.month, self.date.day)
        tomorrow = today.addDays(1)
        
        tommtask = []
        j = i+3
        t = (tomorrow.day(), tomorrow.month(), tomorrow.year(), )
        cur.execute("select * from reminder where day = ? and month = ? and year = ?", t)
        a = cur.fetchone()
        if a==None:
       
            stickylistgrid.addWidget(QtGui.QLabel("<i>.    No assignments</i>"), j+1, 0)
       
        else:
       
            cur.execute("select * from reminder where day = ? and month = ? and year = ?", t)
            q=0
            for row in cur:
                tommtask.append(QtGui.QLabel('   '+str(q+1)+'. '+str(row[0])+' - '+str(row[1])))
                stickylistgrid.addWidget(tommtask[q], j+1, 0)
                q = q+1
                j = j+1

        stickylistgrid.addWidget(QtGui.QLabel("        "), j+2, 0)        
        stickylist.setLayout(stickylistgrid)
        self.ui.stickynote.setWidget(stickylist)

    def setpics(self):
                
        self.ui.home.setIcon(QtGui.QIcon('./pics/home.png'))
        self.ui.calendar.setIcon(QtGui.QIcon('./pics/calendar.png'))
        self.ui.timetable.setIcon(QtGui.QIcon('./pics/timetable.png'))
        self.ui.cgcalc.setIcon(QtGui.QIcon('./pics/grades.png'))
        self.ui.editsem.setIcon(QtGui.QIcon('./pics/editsem.png'))
        self.ui.about.setIcon(QtGui.QIcon('./pics/about.png'))
        self.ui.defsem.setIcon(QtGui.QIcon('./pics/default.png'))
        self.ui.help.setIcon(QtGui.QIcon('./pics/help.png'))
        
        palette = QtGui.QPalette()
        palette.setBrush(self.backgroundRole(), QBrush(QImage("./pics/sticky note.png")))


        palette3 = QtGui.QPalette()
        palette3.setBrush(self.backgroundRole(), QBrush(QImage("./pics/calender.png")))

        palette2 = QtGui.QPalette()
        palette2.setBrush(self.backgroundRole(), QBrush(QImage("./pics/background2.jpg")))

        self.setPalette(palette2)
        self.ui.stickynote.setPalette(palette)
        
        
        
        self.ui.calender.setPalette(palette3)


    def settoolbar(self):
        self.ui.toolBar.addWidget(self.ui.home)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.calendar)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.timetable)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.cgcalc)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.editsem)
        self.ui.toolBar.addSeparator()
        
        aha = QtGui.QWidget()
        aha.setFixedWidth(40)
        aha.setFixedHeight(30)
        

        self.ui.toolBar.addWidget(aha)
        
        self.ui.toolBar.addWidget(self.ui.defsem)
        self.ui.toolBar.addSeparator()

        aha2 = QtGui.QWidget()
        aha.setFixedWidth(40)
        aha.setFixedHeight(30)


        self.ui.toolBar.addWidget(aha2)
        
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.about)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.help)
        self.ui.toolBar.addSeparator()        
 


        self.ui.home.setToolTip('Home')
        self.ui.calendar.setToolTip('Calendar')
        self.ui.timetable.setToolTip('Timetable')
        self.ui.cgcalc.setToolTip('Grades')
        self.ui.editsem.setToolTip('Add / Delete Subjects')
        self.ui.about.setToolTip('About')
        self.ui.defsem.setToolTip('Set Default Semester')
        self.ui.help.setToolTip('Help')
Esempio n. 5
0
class Startmain(QtGui.QMainWindow):
    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_window2()
        self.ui.setupUi(self)
        self.setWindowTitle('acadmin - Academic Management Tool')

        icon = QtGui.QIcon()
        b = QtGui.QPixmap("./pics/logo.png")
        icon.addPixmap(b)

        self.setWindowIcon(icon)

        self.setFixedWidth(931)
        self.setFixedHeight(668)

        b = QtGui.QPixmap("./pics/hide.png")
        self.ui.hide.setPixmap(QtGui.QPixmap(b))

        self.subtabWidget = QtGui.QTabWidget()

        self.dummybutton2 = QtGui.QToolButton()

        self.setdate()
        self.setsem()
        self.setallwidgets()
        self.setsub()
        self.setmaintabwidget()
        self.checkdb()

        self.setpics()
        self.settoolbar()

        self.setstickynote()

        self.editsub = Starteditsub()

        QtCore.QObject.connect(self.ui.maintabWidget,
                               QtCore.SIGNAL("currentChanged(int)"),
                               self.timetabletab)
        QtCore.QObject.connect(self.editsub.ui.change,
                               QtCore.SIGNAL("clicked()"), self.setsub)
        QtCore.QObject.connect(self.ui.cgcalc, QtCore.SIGNAL("clicked()"),
                               self.showcg)
        QtCore.QObject.connect(self.ui.calendar, QtCore.SIGNAL("clicked()"),
                               self.showcalendar)
        QtCore.QObject.connect(self.ui.home, QtCore.SIGNAL("clicked()"),
                               self.showhome)
        QtCore.QObject.connect(self.ui.timetable, QtCore.SIGNAL("clicked()"),
                               self.showtimetable)
        QtCore.QObject.connect(self.ui.editsem, QtCore.SIGNAL("clicked()"),
                               self.showeditsem)
        QtCore.QObject.connect(self.ui.defsem, QtCore.SIGNAL("clicked()"),
                               self.defaultsem)
        QtCore.QObject.connect(self.ui.about, QtCore.SIGNAL("clicked()"),
                               self.showabout)
        QtCore.QObject.connect(self.ui.help, QtCore.SIGNAL("clicked()"),
                               self.showhelp)

        self.clickflag = 0
        self.clickflag2 = 0
        self.ttflag = 0
        self.cgflag = 0

    def showhelp(self):
        self.help = Starthelp()
        self.help.show()

    def checkdb(self):
        cur.execute("select * from acads")
        a = cur.fetchone()

        if a == None:
            self.ui.maintabWidget.setCurrentIndex(1)
            message = QtGui.QMessageBox(self)
            message.setText('Welcome to "acadmin". Start by adding a subject.')
            message.setWindowTitle('Acadmin alert')
            message.setIcon(QtGui.QMessageBox.Information)
            message.exec_()

    def showabout(self):
        self.showabt = Startabout()
        self.showabt.show()

    def showcalendar(self):
        self.ui.maintabWidget.setCurrentIndex(2)

    def showhome(self):
        self.ui.maintabWidget.setCurrentIndex(0)

    def showeditsem(self):
        self.ui.maintabWidget.setCurrentIndex(1)

    def showtimetable(self):
        self.ui.maintabWidget.setCurrentIndex(3)
        if self.clickflag != 1:
            self.clickflag = 1
            self.ui.timetable.click()

    def showcg(self):
        self.ui.maintabWidget.setCurrentIndex(4)
        if self.clickflag2 != 1:
            self.clickflag2 = 1
            self.ui.cgcalc.click()

    def defaultsem(self):
        cur.execute("select * from acads")
        a = cur.fetchone()

        if a == None:
            self.showmessage('Add a subject first')
            self.ui.editsem.click()
        else:
            self.setdefaultsem = Startdefaultsem()
            self.setdefaultsem.show()
            QtCore.QObject.connect(self.setdefaultsem.ui.okay,
                                   QtCore.SIGNAL("clicked()"),
                                   self.setdefsemandclose)

    def setdefsemandclose(self):
        self.setsem()
        self.close()

    def timetabletab(self):
        a = self.ui.maintabWidget.currentIndex()

        b = self.ttflag
        c = self.cgflag

        if a == 3:
            if b == 0:
                self.settimetable()

            if self.ui.maintabWidget.count() > 5:
                self.ui.maintabWidget.removeTab(4)

        if a == 4:
            if c == 0:
                self.cgcalc()

            if self.ui.maintabWidget.count() > 5:
                self.ui.maintabWidget.removeTab(5)

    def setallwidgets(self):
        if self.ui.sem.text() == '':
            sem = None
        else:
            sem = int(self.ui.sem.text())

        self.editsem = Starteditsem()
        self.calendar = Startcalendar(sem)

    def setmaintabwidget(self):
        self.notrequired = QtGui.QWidget()
        self.notrequired2 = QtGui.QWidget()
        self.ui.maintabWidget.clear()
        self.ui.maintabWidget.insertTab(0, self.subtabWidget, 'Home')
        self.ui.maintabWidget.insertTab(1, self.editsem, 'Add/Delete Subjects')
        self.editsemsignals()
        self.ui.maintabWidget.insertTab(2, self.calendar, 'Calendar')
        self.calendarsignals()
        self.ui.maintabWidget.insertTab(3, self.notrequired, 'Timetable')
        self.ui.maintabWidget.insertTab(4, self.notrequired2, 'Grades')

    def cgcalc(self):

        cur.execute("select * from grades")
        a = cur.fetchone()

        if a == None:
            self.showmessage('Set default grading system first')

            self.gradingsystem = Startgrade()
            self.gradingsystem.show()
            QtCore.QObject.connect(self.gradingsystem.ui.done,
                                   QtCore.SIGNAL("clicked()"), self.cgcalc)

        else:
            cur.execute("select * from acads")
            a = cur.fetchone()

            if a == None:
                self.showmessage('Add a subject first')
            else:

                self.cgcalc2 = Startcgcalc()
                self.ui.maintabWidget.insertTab(4, self.cgcalc2, 'Grades')
                self.cgflag = 1
                cur.execute("insert into cgflag values(1)")
                con.commit()

    def settimetable(self):

        cur.execute("select max(day) from timetable")
        a = cur.fetchone()

        if a[0] == None:
            cur.execute("select * from days")
            b = cur.fetchone()

            if b == None:
                self.showmessage('Set timeslots and Days first')
                self.ttdetails = Startttdetailsex()
                self.ttdetails.show()
                QtCore.QObject.connect(self.ttdetails.done,
                                       QtCore.SIGNAL("clicked()"),
                                       self.settimetable)
                QtCore.QObject.connect(self.ttdetails.cancel,
                                       QtCore.SIGNAL("clicked()"),
                                       self.settimetable)

            else:
                cur.execute("select * from acads")
                a = cur.fetchone()
                if a == None:
                    self.showmessage('Add a subject first')

                else:
                    self.showmessage('Set the periods and save')
                    self.ttedit = Starttimetableedit()
                    self.ttedit.show()

                    QtCore.QObject.connect(self.ttedit.save,
                                           QtCore.SIGNAL("clicked()"),
                                           self.settimetable)

        else:

            self.timetable = Starttimetable()

            self.ui.maintabWidget.insertTab(3, self.timetable, 'Timetable')
            self.ttflag = 1
            cur.execute("insert into timetableflag values(1)")
            con.commit()

    def calendarsignals(self):

        QtCore.QObject.connect(self.calendar.savebunk,
                               QtCore.SIGNAL("clicked()"), self.setsub)
        QtCore.QObject.connect(self.calendar.t.ui.add,
                               QtCore.SIGNAL("clicked()"), self.setstickynote)
        QtCore.QObject.connect(self.calendar.dummybutton,
                               QtCore.SIGNAL("clicked()"), self.setstickynote)

    def editsemsignals(self):

        QtCore.QObject.connect(self.editsem.ui.add, QtCore.SIGNAL("clicked()"),
                               self.setsub2)
        QtCore.QObject.connect(self.editsem.ui.delete_2,
                               QtCore.SIGNAL("clicked()"), self.setsub2)

    def setsub(self):

        self.subtabWidget.clear()
        self.startframe = []

        if self.ui.sem.text() != '':
            c = (int(self.ui.sem.text()), )
            cur.execute("select * from acads where semester = ?", c)

            i = 0
            k = 0

            subcode = []
            subname = []
            credits = []
            bunksleft = []
            classes = []
            attendance = []

            for row in cur:
                subcode.append(row[1])
                subname.append(row[2])
                credits.append(row[3])
                bunksleft.append(row[5] - row[6])
                classes.append(row[7])
                attendance.append(row[8])
                k = k + 1

            for i in range(0, k):
                self.startframe.append(
                    Startframe(str(subcode[i]), classes[i], attendance[i]))
                a = self.subtabWidget.insertTab(i, self.startframe[i],
                                                subcode[i])
                self.startframe[i].subjectname.setText(subname[i])
                self.startframe[i].credits.setText(str(credits[i]))
                self.startframe[i].subjectcode.setText(str(subcode[i]))
                self.startframe[i].bunksleft.setText(str(bunksleft[i]))
                QtCore.QObject.connect(
                    self.startframe[i].editsubject.ui.change,
                    QtCore.SIGNAL("clicked()"), self.setsub3)
                QtCore.QObject.connect(self.startframe[i].addref.ui.add,
                                       QtCore.SIGNAL("clicked()"),
                                       self.setsub3)
                QtCore.QObject.connect(
                    self.startframe[i].deleteref.ui.deletebutton,
                    QtCore.SIGNAL("clicked()"), self.setsub3)
                i = i + 1

        self.ui.maintabWidget.removeTab(0)
        self.ui.maintabWidget.insertTab(0, self.subtabWidget, 'Home')

    def setsub3(self):
        self.setsub()
        self.ui.home.click()

    def setsub2(self):

        flag = 0

        cur.execute("select * from acads")

        for row in cur:
            flag = flag + 1

        self.setsem()
        self.setsub()
        self.calendar.setbunkclasses()
        self.calendar.setbunkticks()
        self.ui.home.click()

        if flag == 1:
            self.ui.defsem.click()

    def setsem(self):
        cur.execute("select * from defsem")
        a = cur.fetchone()

        if a != None:
            self.ui.sem.setText(str(a[0]))

    def showmessage(self, a):
        message = QtGui.QMessageBox(self)
        message.setText(a)
        message.setWindowTitle('Acadmin alert')
        message.setIcon(QtGui.QMessageBox.Warning)
        message.exec_()

    def setdate(self):

        self.date = datetime.datetime.now()
        self.month = [
            None,
            'Jan.',
            'Feb.',
            'March',
            'April',
            'May',
            'June',
            'July',
            'Aug.',
            'Sept.',
            'Oct.',
            'Nov.',
            'Dec.',
        ]

        self.ui.day.setText(
            "<span style=\" font-size:48pt; font-weight:600; color:#ffff00;\">"
            + str(self.date.day) + "</span>")
        self.ui.monthyear.setText(
            "<span style=\" font-size:12pt; font-weight:600; color:#ffff00;\">"
            + self.month[self.date.month] + "  " + str(self.date.year) +
            "</span>")
        self.ui.day.setAlignment(Qt.AlignHCenter)
        self.ui.monthyear.setAlignment(Qt.AlignHCenter)

    def setstickynote(self):

        stickylist = QtGui.QWidget()
        stickylist.setSizePolicy(QtGui.QSizePolicy.Expanding,
                                 QtGui.QSizePolicy.Expanding)
        stickylistgrid = QtGui.QGridLayout()

        stickylistgrid.addWidget(QtGui.QLabel("        "), 0, 0)
        stickylistgrid.addWidget(QtGui.QLabel("<b>.  Today's Tasks :</b>"), 1,
                                 0)

        todaytask = []
        i = 0
        t = (
            self.date.day,
            self.date.month,
            self.date.year,
        )
        cur.execute(
            "select * from reminder where day = ? and month = ? and year = ?",
            t)
        a = cur.fetchone()

        if a == None:
            stickylistgrid.addWidget(
                QtGui.QLabel("<i>.    No assignments</i>"), 2, 0)

        else:

            cur.execute(
                "select * from reminder where day = ? and month = ? and year = ?",
                t)
            for row in cur:
                todaytask.append(
                    QtGui.QLabel('   ' + str(i + 1) + '. ' + str(row[0]) +
                                 ' - ' + str(row[1])))
                stickylistgrid.addWidget(todaytask[i], i + 2, 0)
                i = i + 1

        stickylistgrid.addWidget(QtGui.QLabel("<b>.  Tomorrow's Tasks :</b>"),
                                 i + 3, 0)

        today = QtCore.QDate(self.date.year, self.date.month, self.date.day)
        tomorrow = today.addDays(1)

        tommtask = []
        j = i + 3
        t = (
            tomorrow.day(),
            tomorrow.month(),
            tomorrow.year(),
        )
        cur.execute(
            "select * from reminder where day = ? and month = ? and year = ?",
            t)
        a = cur.fetchone()
        if a == None:

            stickylistgrid.addWidget(
                QtGui.QLabel("<i>.    No assignments</i>"), j + 1, 0)

        else:

            cur.execute(
                "select * from reminder where day = ? and month = ? and year = ?",
                t)
            q = 0
            for row in cur:
                tommtask.append(
                    QtGui.QLabel('   ' + str(q + 1) + '. ' + str(row[0]) +
                                 ' - ' + str(row[1])))
                stickylistgrid.addWidget(tommtask[q], j + 1, 0)
                q = q + 1
                j = j + 1

        stickylistgrid.addWidget(QtGui.QLabel("        "), j + 2, 0)
        stickylist.setLayout(stickylistgrid)
        self.ui.stickynote.setWidget(stickylist)

    def setpics(self):

        self.ui.home.setIcon(QtGui.QIcon('./pics/home.png'))
        self.ui.calendar.setIcon(QtGui.QIcon('./pics/calendar.png'))
        self.ui.timetable.setIcon(QtGui.QIcon('./pics/timetable.png'))
        self.ui.cgcalc.setIcon(QtGui.QIcon('./pics/grades.png'))
        self.ui.editsem.setIcon(QtGui.QIcon('./pics/editsem.png'))
        self.ui.about.setIcon(QtGui.QIcon('./pics/about.png'))
        self.ui.defsem.setIcon(QtGui.QIcon('./pics/default.png'))
        self.ui.help.setIcon(QtGui.QIcon('./pics/help.png'))

        palette = QtGui.QPalette()
        palette.setBrush(self.backgroundRole(),
                         QBrush(QImage("./pics/sticky note.png")))

        palette3 = QtGui.QPalette()
        palette3.setBrush(self.backgroundRole(),
                          QBrush(QImage("./pics/calender.png")))

        palette2 = QtGui.QPalette()
        palette2.setBrush(self.backgroundRole(),
                          QBrush(QImage("./pics/background2.jpg")))

        self.setPalette(palette2)
        self.ui.stickynote.setPalette(palette)

        self.ui.calender.setPalette(palette3)

    def settoolbar(self):
        self.ui.toolBar.addWidget(self.ui.home)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.calendar)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.timetable)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.cgcalc)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.editsem)
        self.ui.toolBar.addSeparator()

        aha = QtGui.QWidget()
        aha.setFixedWidth(40)
        aha.setFixedHeight(30)

        self.ui.toolBar.addWidget(aha)

        self.ui.toolBar.addWidget(self.ui.defsem)
        self.ui.toolBar.addSeparator()

        aha2 = QtGui.QWidget()
        aha.setFixedWidth(40)
        aha.setFixedHeight(30)

        self.ui.toolBar.addWidget(aha2)

        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.about)
        self.ui.toolBar.addSeparator()
        self.ui.toolBar.addWidget(self.ui.help)
        self.ui.toolBar.addSeparator()

        self.ui.home.setToolTip('Home')
        self.ui.calendar.setToolTip('Calendar')
        self.ui.timetable.setToolTip('Timetable')
        self.ui.cgcalc.setToolTip('Grades')
        self.ui.editsem.setToolTip('Add / Delete Subjects')
        self.ui.about.setToolTip('About')
        self.ui.defsem.setToolTip('Set Default Semester')
        self.ui.help.setToolTip('Help')
Esempio n. 6
0
class Startcgcalc(QtGui.QMainWindow):

    sub = ()
    credit = ()
    grade = ()
    numeqdict = {}
    
    # Setting the semester.
    
    def setsem(self):
        cur.execute("select distinct semester from acads")
        a = cur.fetchall()
        
        b = []
        
        for sublist in a:
            b.append(str(sublist[0]))
            
        self.ui.sem.clear()
        self.ui.sem.addItems(b)
        cur.execute("select * from defsem")
        a = cur.fetchone()


        if a!=None:
            self.ui.sem.setCurrentIndex(self.ui.sem.findText(str(a[0])))

    def __init__(self, parent=None):
        QtGui.QWidget.__init__(self, parent)
        self.ui = Ui_window()
        self.ui.setupUi(self)
        self.editgrades = Startgrade()
        

        self.setsem()
        self.ui.sem.setVisible(False)
        self.sub = (self.ui.sub1, self.ui.sub2, self.ui.sub3, self.ui.sub4, self.ui.sub5, self.ui.sub6, self.ui.sub7, self.ui.sub8, self.ui.sub9, self.ui.sub10, )
        
        self.credit = (self.ui.credit1, self.ui.credit2, self.ui.credit3, self.ui.credit4, self.ui.credit5, self.ui.credit6, self.ui.credit7, self.ui.credit8, self.ui.credit9, self.ui.credit10, )

        self.grade = (self.ui.grade1, self.ui.grade2, self.ui.grade3, self.ui.grade4, self.ui.grade5, self.ui.grade6, self.ui.grade7, self.ui.grade8, self.ui.grade9, self.ui.grade10, ) 
        
        self.gradeinvisible()
        self.clear()
        self.setgrade1()
        self.setsub()

        self.setnumeqdict()
        self.setgrade2()
        
        for i in range(0, 10):
            self.grade[i].setStyleSheet('selection-background-color: rgb(85, 85, 255); selection-color: rgb(255, 255, 255)')            
        
        QtCore.QObject.connect(self.ui.sem, QtCore.SIGNAL("currentIndexChanged(int)"), self.setsub)
        QtCore.QObject.connect(self.ui.cgpa_button, QtCore.SIGNAL("clicked()"), self.calc_cgpa)
        QtCore.QObject.connect(self.ui.gpa_button, QtCore.SIGNAL("clicked()"), self.calc_gpa)
        QtCore.QObject.connect(self.ui.editgrades, QtCore.SIGNAL("clicked()"), self.editgradesed)
        QtCore.QObject.connect(self.ui.save, QtCore.SIGNAL("clicked()"), self.saved)

        self.ui.cgpa_button.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')
        self.ui.gpa_button.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')
        self.ui.editgrades.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')        
        self.ui.save.setStyleSheet('background-color: rgb(0, 147, 203); color: rgb(255, 255, 255);')        
                
	
	# Calculating the sum of credits.
	
    def creditsum(self, a):
        t = (a, )
        cur.execute("select * from acads where semester = ? and grade<>'null'", t)
        
        creditsum = 0
        
        for row in cur:
            creditsum = creditsum + row[3]
        
        return creditsum

    # Checking conditions prior to opening the cgpa frame.
    
    def calc_cgpa(self):

        cur.execute("select distinct semester from acads")
        
        flag = 0
        
        for row in cur:
            if self.creditsum(int(row[0]))==0:
                flag = 1
                break;

        if flag==0:
	    self.ui.cgpa_button.setText("Please wait")
#            os.system("python './graph.py'")
            self.cgpa = Startcgpa2()
            self.cgpa.show()
    
        else :
            self.showmessage("One of the semester's credit sum is 0 ")

	# Storing the grades into database.

    def saved(self):
        if self.ui.sem.currentText()!='':
            
            c = (int(self.ui.sem.currentText()),)
            
            cur.execute("select count(subjectcode) from acads where semester = ?", c)
            a = cur.fetchone()
            con.commit()
            i=0
            while(i<a[0]):
                if self.grade[i].currentIndex()!=0:
                    t= (str(self.grade[i].currentText()), str(self.sub[i].text()), int(self.ui.sem.currentText()), )
                    cur.execute("update acads set grade = ? where subjectcode = ? and semester = ?", t)
                    con.commit()
            
                    
                else :
                    t= (None, str(self.sub[i].text()), int(self.ui.sem.currentText()), )
                    cur.execute("update acads set grade = ? where subjectcode = ? and semester = ?", t)
                    con.commit()
                i = i+1
	    os.system("python './graph.py'")
        
    # Calculating the gpa.
    
    def calc_gpa(self):
        
            gpat = 0
            creditsum = 0
            c = (int(self.ui.sem.currentText()),)
            cur.execute("select count(subjectcode) from acads where semester = ?", c)
            a = cur.fetchone()

            i = 0;
            while(i<a[0]):
                if self.grade[i].currentIndex()!=0:
                    gpat = gpat + int(self.credit[i].text())*self.numeqdict[str(self.grade[i].currentText())]
                    creditsum = creditsum + int(self.credit[i].text())
                i = i+1
            
            self.ui.crthsem.setText(str(creditsum))
            
            if creditsum!=0:
                
                gpa = float(gpat)/creditsum
                gp = "%.2f" % (gpa) 
                self.ui.gpa.setText(str(gp))
            
            else:
                self.showmessage('Credit sum is 0')

	# Error message
                        
    def showmessage(self, a):
        message = QtGui.QMessageBox(self)
        message.setText(a)
        message.setWindowTitle('acadmin Error')
        message.setIcon(QtGui.QMessageBox.Critical)
        message.exec_()

	# Making the UI of grades only visible if subject is there.

    def gradeinvisible(self):
        i = 0
        
        while(i<10):
            self.grade[i].setVisible(False)
            i= i+1
    
    # Filling in the subjects of the selected semester
    
    def setsub(self):
            
        if self.ui.sem.currentText()!='':
            c = (int(self.ui.sem.currentText()),)
            
            cur.execute("select * from acads where semester = ?", c)
        
            i=0
            while(i<10):
                self.sub[i].clear()
                self.credit[i].clear()
                self.grade[i].setVisible(False)
                i = i+1
            self.ui.crthsem.clear()
            self.ui.gpa.clear()
            i=0
            for row in cur:
                self.sub[i].setText(row[1])
                self.credit[i].setText(str(row[3]))
                self.grade[i].setVisible(True)
                
                if row[4]!=None:
                    a = self.grade[i].findText(row[4],Qt.MatchExactly)
                    self.grade[i].setCurrentIndex(a)
                else:
                    self.grade[i].setCurrentIndex(0)

                i = i+1;
    
    # Clearing the frame for other semester
    
    def clear(self):
        i=0
        while(i<10):
            self.sub[i].clear()
            self.credit[i].clear()
            self.grade[i].clear()
            i = i+1
        
    
    # Setting the grades for respective subjects.
    
    def setgrade1(self):
        cur.execute("select grade from grades")
        
        a = cur.fetchall()
        
        b = ['']
        
        for sublist in a:
            b.append(str(sublist[0]))
        
        i = 0
        while (i<10):
            self.grade[i].addItems(b)
            i = i+1
        
    # Getting the numeric equivalent of the grades.
    
    def setnumeqdict(self):
        cur.execute("select * from grades")
        for row in cur:
            self.numeqdict[row[0]] = row[1]
            
    # For opening the frame to change the grades and their decimal equivalents.
    
    def editgradesed(self):
        self.editgrades.show()
    
    # Setting the grades.
    
    def setgrade2(self):
        if self.ui.sem.currentText()!='':
            c = (int(self.ui.sem.currentText()),)
            
            cur.execute("select * from acads where semester = ?", c)