Exemplo n.º 1
0
    def getgrade(self):
        """initialize TableView"""
        getitems=GetItems()
        stuid=self.lineStuid.text()
        pwd=self.linePwd.text()
        if stuid=="" or pwd=="":
            QMessageBox.information(self, 'Warning', self.tr("用户名或密码错误!"))
        else:
            self.tableWidget.setRowCount(0)
            self.tableWidget.clearContents()
            getitems.setpost(stuid, pwd)
            getitems.getauthstatus()
            if getitems.isAuth==False:
                QMessageBox.information(self, "Warning", self.tr("用户名或密码错误!"))
            else:
                self.myItems=getitems.getgrade()
                row=0
                col=0
#        self.newItem = QTableWidgetItem('Item')
#        self.tableWidget.insertRow(0)
#        self.tableWidget.setItem(0,0,self.newItem)
                for row in range(len(self.myItems)):
                    self.tableWidget.insertRow(row)
                    self.checkbox=QCheckBox(self)
                    self.tableWidget.setCellWidget(row, 0, self.checkbox)
                    for col in range(len(self.myItems[0])):
                        self.newItem = QTableWidgetItem(self.myItems[row][col])
                        self.tableWidget.setItem(row,col+1,self.newItem)
                        col=col+1
                    row=row+1
Exemplo n.º 2
0
 def queryclass(self):
     """query classes from website"""
     getitems=GetItems()
     stuid=self.lineStuid.text()
     pwd=self.linePwd.text()
     if stuid=="" or pwd=="":
         QMessageBox.information(self, "Warning", self.tr("用户名或密码错误!"))
     else:
         currentWeek=int(self.comboBox.currentText())
         getitems.setpost(stuid, pwd)
         getitems.getauthstatus()
         if getitems.isAuth==False:
             QMessageBox.information(self, "Warning", self.tr("用户名或密码错误!"))
         else:
             self.cleartable()
             self.myItems=getitems.getclass()
             row=0
             col=0
             for row in range(len(self.myItems)):
                 for col in range(len(self.myItems[0])):
                     self.item=QTableWidgetItem(str(self.myItems[row][0])+'\n         '+str(self.myItems[row][1]))
             
                     tRow=int(self.myItems[row][3])
                     tCol=int(self.myItems[row][2])
                     weekL=int(self.myItems[row][4])
                     weekH=int(self.myItems[row][5])
                     if currentWeek<=weekH and currentWeek>=weekL:
                         self.tableWidget.setItem(tRow-1, tCol-1, self.item)