def removelist1(self,item): date=side_sql.fetch_roll(item.text()) val=side_sql.fetch_value(item.text()) if date[0]=="Bat": print(int(self.l1.text())) self.d=int(self.l1.text()) if self.d<3: self.d+=1 self.l1.setText(str(self.d)) self.lw1.takeItem(self.lw1.row(item)) self.lw2.addItem(item.text()) self.cal_points1(item) else: store="Only three batsman can be present" sample.MainWindow(store) if date[0]=="Ball": print(int(self.l2.text())) self.d=int(self.l2.text()) if self.d<3: self.d+=1 self.l2.setText(str(self.d)) self.lw1.takeItem(self.lw1.row(item)) self.lw2.addItem(item.text()) self.cal_points1(item) else: store="Only three bowlers can be present" sample.MainWindow(store) if date[0]=="AR": print(int(self.l4.text())) self.d=int(self.l4.text()) if self.d<2: self.d+=1 self.l4.setText(str(self.d)) self.lw1.takeItem(self.lw1.row(item)) self.lw2.addItem(item.text()) self.cal_points1(item) else: store="Only two all rounder can be present" sample.MainWindow(store) if date[0]=="WK": print(int(self.l3.text())) self.d=int(self.l3.text()) if self.d==0: self.d+=1 self.l3.setText(str(self.d)) self.lw1.takeItem(self.lw1.row(item)) self.lw2.addItem(item.text()) self.cal_points1(item) else: store="Only one wcket keeper can be present" sample.MainWindow(store)
def terminate(self): value = 0 self.name = self.cb1.currentText() + "_" + self.cb2.currentText() for i in range(self.lw2.count()): value = value + int(self.lw2.item(i).text()) store = "The total scored is %d" % value sample.MainWindow(store)
def store_team(nm, l): name = str(nm) pl = l demo = sqlite3.connect("fantasy_cricket.db") uemo = demo.cursor() if len(l) <= 8: store = "Team not formed.Total nine member must be present." sample.MainWindow(store) else: for i in range(len(pl)): val = fetch_value(pl[i]) uemo.execute("insert into teams(name,players,value)values(?,?,?);", (name, pl[i], val[0])) demo.commit()
def openning(self): record=side_sql.retrieve_team(self.l7.text()) self.lw2.clear() self.lw1.clear() self.l5.setText(str(1000)) self.l1.setText(str(0)) self.l2.setText(str(0)) self.l3.setText(str(0)) self.l4.setText(str(0)) self.l6.setText(str(0)) self.rb1.setCheckable(False) self.rb2.setCheckable(False) self.rb3.setCheckable(False) self.rb4.setCheckable(False) if record==[]: store="Team doesnot exist." sample.MainWindow(store) else: for i in range(len(record)): self.lw2.addItem(record[i][0]) store="You cant change the team,so dont click on players,if you did you will crash." self.l7.setReadOnly(True) self.lw2.setEnabled(False)
def menufunction(self,action): txt=(action.text()) if txt=="Evaluate Team": self.lw1.clear() self.lw2.clear() self.l5.setText(str(1000)) self.l7.clear() self.l7.setReadOnly(True) self.l1.setText(str(0)) self.l2.setText(str(0)) self.l3.setText(str(0)) self.l4.setText(str(0)) self.l6.setText(str(0)) self.rb1.setCheckable(False) self.rb2.setCheckable(False) self.rb3.setCheckable(False) self.rb4.setCheckable(False) self.lw2.setEnabled(True) record=side_sql.fetch_teamname() if record==[]: store="Enter the Teams first." sample.MainWindow(store) else: self.Form = QtWidgets.QWidget() self.ui = back.Ui_Form() self.ui.setupUi(self.Form) self.Form.show() if txt=="New Team": self.l7.clear() store="Enter the name of the team at team name line and choose your players:" self.lw2.setEnabled(True) sample.MainWindow(store) self.l7.setReadOnly(False) self.rb1.setCheckable(True) self.rb2.setCheckable(True) self.rb3.setCheckable(True) self.rb4.setCheckable(True) self.lw2.clear() self.lw1.clear() if txt=="Save Team": record=side_sql.fetch_teamname() self.lw2.setEnabled(True) print(record) for i in range(len(record)): if self.l7.text().strip()==record[i][0]: store="Team Already Exist." sample.MainWindow(store) self.lw1.clear() self.lw2.clear() self.l5.setText(str(1000)) self.l7.clear() self.l7.setReadOnly(True) self.l1.setText(str(0)) self.l2.setText(str(0)) self.l3.setText(str(0)) self.l4.setText(str(0)) self.l6.setText(str(0)) self.rb1.setCheckable(False) self.rb2.setCheckable(False) self.rb3.setCheckable(False) self.rb4.setCheckable(False) if self.l7.text().strip()=="": store="enter valid name." sample.MainWindow(store) self.lw1.clear() self.lw2.clear() self.l5.setText(str(1000)) self.l7.clear() self.l7.setReadOnly(True) self.l1.setText(str(0)) self.l2.setText(str(0)) self.l3.setText(str(0)) self.l4.setText(str(0)) self.l6.setText(str(0)) self.rb1.setCheckable(False) self.rb2.setCheckable(False) self.rb3.setCheckable(False) self.rb4.setCheckable(False) else: items=[] for index in range(self.lw2.count()): items.append(self.lw2.item(index).text()) side_sql.store_team(self.l7.text(),items) self.lw1.clear() self.lw2.clear() self.l5.setText(str(1000)) self.l7.clear() self.l7.setReadOnly(True) self.l1.setText(str(0)) self.l2.setText(str(0)) self.l3.setText(str(0)) self.l4.setText(str(0)) self.l6.setText(str(0)) self.rb1.setCheckable(False) self.rb2.setCheckable(False) self.rb3.setCheckable(False) self.rb4.setCheckable(False) if txt=="Open Team": self.lw2.clear() store="Enter Team name.And press Enter" sample.MainWindow(store) self.l7.setReadOnly(False) self.l7.returnPressed.connect(self.openning)
def choose(self): store="Now Choose your team" sample.MainWindow(store)