def Add_Team_Data(self): checked=[self.BAT.isChecked(),self.BOW.isChecked(),self.AR.isChecked(),self.WK.isChecked()] sel=["BAT","BOW","AR","WK"] values=[sel[idx] for idx,c in enumerate(checked) if c==True] sql = "select player ||'-'|| ctg from players where ctg='{}'".format(values[0]) self.check2 = [] for i in range(self.listWidget_2.count()): items = self.listWidget_2.item(i).text() self.check2.append(items) #get Data d1=DataHandler() data=d1.FetchItems(sql) players=[d[0] for d in data] self.listWidget.clear() if(len(players)!=0): for i in range(len(players)): item = QtWidgets.QListWidgetItem(players[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(100) item.setFont(font) item.setBackground(QtGui.QColor('light gray')) if(players[i] in self.check2): item.setForeground(QtGui.QColor('red')) self.listWidget.addItem(item)
def Evaluate_Score(self): d1 = DataHandler() t = "select name,value from teams" teams = d1.FetchItems(t) allteams = [t[0] for t in teams] self.evaluate_screen.cbteam.addItem("Select Team") for i in range(len(allteams)): self.evaluate_screen.cbteam.addItem(allteams[i]) self.EvatulateDialog.show()
def Team_Save(self): self.items.clear() for index in range(self.listWidget_2.count()): self.items.append(self.listWidget_2.item(index).text().split("-")[0]) d1=DataHandler() scoresdata = [] for player in self.items: squery="select value from stats where name='{}';".format(player) data=str(d1.FetchItems(squery)[0][0]) scoresdata.append(data) #List = tuple(zip(self.items, score)) name=self.teamname.text() players=",".join(self.items) scores=",".join(scoresdata) if(len(self.items)==11): checkteams="select name from teams where name='{}'".format(name) checkvalue=d1.FetchItems(checkteams) if (len(checkvalue)>0): e = "This Team Name is Already Exists" self.ShowError(e) elif(name=="#####"): e = "Blank Team Name Not Allowed" self.ShowError(e) else: sqladdteam = "Insert into teams (name,players,value) values(?,?,?)" inserteddata = d1.InsertItems(sqladdteam, (name, players, scores)) if(inserteddata=="1"): message="Successfully Saved" self.ShowSuccess(message) else: e = "Something Went Wrong Try Again" self.ShowError(e) else: e = "Please Select At least 11 Players" self.ShowError(e)
def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.label_2.setText(_translate("MainWindow", "Players")) self.label.setText(_translate("MainWindow", "Points")) self.totalpoints.setText(_translate("MainWindow", "0000")) self.Evaluatescore.setText(_translate("MainWindow", "Evaluate Score")) teams = [] match = [] d1 = DataHandler() t = "select name,value from teams" teams = d1.FetchItems(t) #self.totalpnts = [int(t) for t in teams[0][1].split(",")] #self.ttlpnts = sum(self.totalpnts) allteams = [t[0] for t in teams] #self.cbteam.addItem("Select Team") #for i in range(len(allteams)): # self.cbteam.addItem(allteams[i]) self.totalpoints.setText("") self.cbmatch.addItem("Select Match") self.cbmatch.addItem("match")
def FinalScore(self): scores=[] d1 = DataHandler() #Get All Required Coloumns sql = "select * from match;" coloumnslist = d1.Fetchcoloumns(sql) team=self.evaluate_screen.cbteam.currentText() psql ="select players from teams where name='{}'".format(team) pls=list(d1.FetchItems(psql)[0]) playerlist=pls[0].split(",") self.evaluate_screen.pointlist.clear() self.evaluate_screen.playerslist.clear() for index in range(len(playerlist)): playerscore=self.PlayerScoreCalulate(coloumnslist,d1,playerlist[index]) item = QtWidgets.QListWidgetItem(playerlist[index]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) item.setBackground(QtGui.QColor('#ffff99')) self.evaluate_screen.playerslist.addItem(item) self.evaluate_screen.pointlist.addItem(str(playerscore))
def AfterOpenTeam(self): self.selected =self.open_screen.cbteamlist.currentText() if str(self.selected)!="Select": d1=DataHandler() sqlq = "select * from teams where name='{}'".format(self.selected) data = d1.FetchItems(sqlq) TeamName=data[0][0] players=data[0][1].split(",") self.listWidget_2.clear() self.teamname.setText(TeamName) for i in range(len(players)) : item = QtWidgets.QListWidgetItem(players[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(100) item.setFont(font) item.setBackground(QtGui.QColor('light gray')) self.listWidget_2.addItem(item) self.openDialog.close() else: e="Please Select At least one Team" self.ShowError(e)
def GetPlayerpoints(self,name): sql="select value from stats where name='{}'".format(name) d1=DataHandler() data=d1.FetchItems(sql) return data[0][0]