def __init__(self): self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog)
def __init__(self): # linking files and creating objects self.new_Window = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.new_Window) self.evaluate_Window = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.evaluate_Window) self.open_Window = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.open_Window)
class Ui_MainWindow(object): def __init__(self): self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog) # FILE OPENING MENU def file_open(self): self.open_screen.setupUi(self.openDialog) self.openDialog.show() self.open_screen.openbtn.clicked.connect(self.openteam) # EVALUATE TEAM MENU def file_evaluate(self): self.eval_screen.setupUi(self.EvaluateWindow) self.EvaluateWindow.show() def setupUi(self, MainWindow): # INITIALISING POINTS AND COUNTS self.avail_points = 1000 self.used_points = 0 self.totalcount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.alrdscount = 0 self.wicketerscount = 0 # INITIALIZING LISTS self.a = [] # bowler names list self.b = [] # batsman nameslist self.c = [] # allrounder names list self.d = [] #wicketer names list self.list1 = [] # selectedplayer's list MainWindow.setObjectName("MainWindow") MainWindow.resize(556, 523) MainWindow.setStyleSheet("background-color: rgb(255, 255, 255);") self.central_w = QtWidgets.QWidget(MainWindow) self.central_w.setObjectName("central_w") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.central_w) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.verticalLayout_3.addItem(spacerItem) self.frame = QtWidgets.QFrame(self.central_w) self.frame.setStyleSheet("background-color: rgb(241, 235, 255);\n" "font: 75 10pt \"MS Shell Dlg 2\";\n" "") self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame.setFrameShadow(QtWidgets.QFrame.Raised) self.frame.setObjectName("frame") self.gridLayout = QtWidgets.QGridLayout(self.frame) self.gridLayout.setContentsMargins(-1, 5, -1, 24) self.gridLayout.setObjectName("gridLayout") self.BAT = QtWidgets.QLabel(self.frame) self.BAT.setStyleSheet("color: rgb(0, 170, 255);") self.BAT.setObjectName("BAT") self.gridLayout.addWidget(self.BAT, 1, 1, 1, 1) self.label_2 = QtWidgets.QLabel(self.frame) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) self.WK = QtWidgets.QLabel(self.frame) self.WK.setStyleSheet("color: rgb(0, 170, 255);") self.WK.setObjectName("WK") self.gridLayout.addWidget(self.WK, 1, 7, 1, 1) self.label_4 = QtWidgets.QLabel(self.frame) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 1, 2, 1, 1) self.label_10 = QtWidgets.QLabel(self.frame) self.label_10.setObjectName("label_10") self.gridLayout.addWidget(self.label_10, 1, 4, 1, 1) self.ARL = QtWidgets.QLabel(self.frame) self.ARL.setStyleSheet("color: rgb(0, 170, 255);") self.ARL.setObjectName("ARL") self.gridLayout.addWidget(self.ARL, 1, 5, 1, 1) self.BOWL = QtWidgets.QLabel(self.frame) self.BOWL.setStyleSheet("color: rgb(0, 170, 255);") self.BOWL.setObjectName("BOWL") self.gridLayout.addWidget(self.BOWL, 1, 3, 1, 1) self.label_12 = QtWidgets.QLabel(self.frame) self.label_12.setObjectName("label_12") self.gridLayout.addWidget(self.label_12, 1, 6, 1, 1) self.label = QtWidgets.QLabel(self.frame) self.label.setStyleSheet("\n" "font: italic 9pt \"Comic Sans MS\";") self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.verticalLayout_3.addWidget(self.frame) self.frame_2 = QtWidgets.QFrame(self.central_w) self.frame_2.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";\n" "border-color: rgb(255, 255, 255);") self.frame_2.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_2.setFrameShadow(QtWidgets.QFrame.Plain) self.frame_2.setLineWidth(0) self.frame_2.setObjectName("frame_2") self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame_2) self.horizontalLayout.setContentsMargins(46, 8, 23, 5) self.horizontalLayout.setObjectName("horizontalLayout") self.label_6 = QtWidgets.QLabel(self.frame_2) self.label_6.setStyleSheet("font: 75 9pt \"MS Shell Dlg 2\";") self.label_6.setObjectName("label_6") self.horizontalLayout.addWidget(self.label_6) self.points_available = QtWidgets.QLabel(self.frame_2) self.points_available.setStyleSheet("color: rgb(85, 170, 255);") self.points_available.setObjectName("points_available") self.horizontalLayout.addWidget(self.points_available) self.label_7 = QtWidgets.QLabel(self.frame_2) self.label_7.setObjectName("label_7") self.horizontalLayout.addWidget(self.label_7, 0, QtCore.Qt.AlignRight) self.points_used = QtWidgets.QLabel(self.frame_2) self.points_used.setStyleSheet("color: rgb(85, 170, 255);") self.points_used.setObjectName("points_used") self.horizontalLayout.addWidget(self.points_used, 0, QtCore.Qt.AlignHCenter) self.verticalLayout_3.addWidget(self.frame_2) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setObjectName("horizontalLayout_4") spacerItem1 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem1) self.frame_3 = QtWidgets.QFrame(self.central_w) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.frame_3.sizePolicy().hasHeightForWidth()) self.frame_3.setSizePolicy(sizePolicy) self.frame_3.setStyleSheet("border-color: rgb(15, 15, 15);") self.frame_3.setFrameShape(QtWidgets.QFrame.Box) self.frame_3.setFrameShadow(QtWidgets.QFrame.Sunken) self.frame_3.setLineWidth(2) self.frame_3.setMidLineWidth(1) self.frame_3.setObjectName("frame_3") self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_3) self.verticalLayout.setContentsMargins(19, -1, 19, -1) self.verticalLayout.setObjectName("verticalLayout") self.frame_5 = QtWidgets.QFrame(self.frame_3) self.frame_5.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";") self.frame_5.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_5.setFrameShadow(QtWidgets.QFrame.Sunken) self.frame_5.setObjectName("frame_5") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.frame_5) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.bat_rb = QtWidgets.QRadioButton(self.frame_5) # bat_rb sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.bat_rb.sizePolicy().hasHeightForWidth()) self.bat_rb.setSizePolicy(sizePolicy) self.bat_rb.setEnabled(False) self.bat_rb.setTabletTracking(False) self.bat_rb.setAcceptDrops(False) self.bat_rb.setObjectName("bat_rb") self.horizontalLayout_2.addWidget(self.bat_rb) self.bow_rb = QtWidgets.QRadioButton(self.frame_5) #bat_rb sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) self.bow_rb.setEnabled(False) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.bow_rb.sizePolicy().hasHeightForWidth()) self.bow_rb.setSizePolicy(sizePolicy) self.bow_rb.setObjectName("bow_rb") self.horizontalLayout_2.addWidget(self.bow_rb) self.ar_rb = QtWidgets.QRadioButton(self.frame_5) #ar_rb sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth( self.ar_rb.sizePolicy().hasHeightForWidth()) self.ar_rb.setSizePolicy(sizePolicy) self.ar_rb.setEnabled(False) self.ar_rb.setObjectName("ar_rb") self.horizontalLayout_2.addWidget(self.ar_rb) self.wk_rb = QtWidgets.QRadioButton(self.frame_5) #wk_rb sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) self.wk_rb.setEnabled(False) sizePolicy.setHeightForWidth( self.wk_rb.sizePolicy().hasHeightForWidth()) self.wk_rb.setSizePolicy(sizePolicy) self.wk_rb.setObjectName("wk_rb") self.horizontalLayout_2.addWidget(self.wk_rb) self.verticalLayout.addWidget(self.frame_5) #available_players self.av_player = QtWidgets.QListWidget(self.frame_3) self.av_player.setFrameShape(QtWidgets.QFrame.NoFrame) self.av_player.setObjectName("av_player") self.verticalLayout.addWidget(self.av_player) self.horizontalLayout_4.addWidget(self.frame_3) spacerItem2 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem2) self.label_9 = QtWidgets.QLabel(self.central_w) self.label_9.setStyleSheet("font: 20pt \"MS Shell Dlg 2\";") self.label_9.setLineWidth(-10) self.label_9.setMidLineWidth(-10) self.label_9.setObjectName("label_9") self.horizontalLayout_4.addWidget(self.label_9) spacerItem3 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem3) self.frame_4 = QtWidgets.QFrame(self.central_w) self.frame_4.setFrameShape(QtWidgets.QFrame.Box) self.frame_4.setFrameShadow(QtWidgets.QFrame.Sunken) self.frame_4.setLineWidth(2) self.frame_4.setMidLineWidth(1) self.frame_4.setObjectName("frame_4") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_4) self.verticalLayout_2.setContentsMargins(18, 9, 14, -1) self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setObjectName("verticalLayout_2") self.frame_6 = QtWidgets.QFrame(self.frame_4) self.frame_6.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";") self.frame_6.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_6.setFrameShadow(QtWidgets.QFrame.Raised) self.frame_6.setObjectName("frame_6") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.frame_6) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_8 = QtWidgets.QLabel(self.frame_6) self.label_8.setObjectName("label_8") self.horizontalLayout_3.addWidget(self.label_8, 0, QtCore.Qt.AlignHCenter) self.team_name = QtWidgets.QLabel(self.frame_6) self.team_name.setStyleSheet("color: rgb(85, 170, 255);") self.team_name.setObjectName("team_name") self.horizontalLayout_3.addWidget(self.team_name) self.verticalLayout_2.addWidget(self.frame_6) #select_players self.sel_player = QtWidgets.QListWidget(self.frame_4) self.sel_player.setFrameShape(QtWidgets.QFrame.NoFrame) self.sel_player.setObjectName("sel_player") self.verticalLayout_2.addWidget(self.sel_player) self.horizontalLayout_4.addWidget(self.frame_4) spacerItem4 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem4) self.verticalLayout_3.addLayout(self.horizontalLayout_4) MainWindow.setCentralWidget(self.central_w) self.menubar = QtWidgets.QMenuBar(MainWindow) #Menubar self.menubar.setGeometry(QtCore.QRect(0, 0, 556, 21)) self.menubar.setObjectName("menubar") self.menuManage_Teams = QtWidgets.QMenu(self.menubar) self.menuManage_Teams.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.menuManage_Teams.setStyleSheet("color: rgb(0, 170, 255);") self.menuManage_Teams.setStyleSheet( "background-color: rgb(232, 232, 232);") self.menuManage_Teams.setStyleSheet( "selection-background-color: rgb(0, 170, 255);\n" "\n" "") self.menuManage_Teams.setObjectName("menuManage_Teams") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.new_t = QtWidgets.QAction(MainWindow) #new window self.new_t.setIconText("NEW Team") self.new_t.setShortcut("Ctrl+N") self.new_t.setShortcutContext(QtCore.Qt.WindowShortcut) self.new_t.setVisible(True) self.new_t.setShortcutVisibleInContextMenu(True) self.new_t.setObjectName("new_t") self.open_t = QtWidgets.QAction(MainWindow) #open team self.open_t.setObjectName("open_t") self.save_t = QtWidgets.QAction(MainWindow) #save team self.save_t.setObjectName("save_t") self.evaluate_t = QtWidgets.QAction(MainWindow) #EVALUATETEAM self.evaluate_t.setObjectName("evaluate_t") self.actionQuit = QtWidgets.QAction(MainWindow) # Quitwindow self.actionQuit.setObjectName("actionQuit") self.actionQuit.triggered.connect(self.quit) self.menuManage_Teams.addAction(self.new_t) self.menuManage_Teams.addAction(self.open_t) self.menuManage_Teams.addAction(self.save_t) self.menuManage_Teams.addAction(self.evaluate_t) self.menuManage_Teams.addAction(self.actionQuit) self.menubar.addAction(self.menuManage_Teams.menuAction()) #Action teiggered self.new_t.triggered.connect(self.file_new) self.open_t.triggered.connect(self.file_open) self.save_t.triggered.connect(self.file_save) self.evaluate_t.triggered.connect(self.file_evaluate) self.actionQuit.triggered.connect(self.quit) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) # DOUBLE CLICK self.av_player.itemDoubleClicked.connect(self.removelist1) self.sel_player.itemDoubleClicked.connect(self.removelist2) # -----stats of player self.stats = {} self.new_screen.savename.clicked.connect(self.namechange) # RADIOBUTTONS CLICK self.bat_rb.clicked.connect(self.load_names) self.wk_rb.clicked.connect(self.load_names) self.bow_rb.clicked.connect(self.load_names) self.ar_rb.clicked.connect(self.load_names) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.BAT.setText(_translate("MainWindow", "##")) self.label_2.setText(_translate("MainWindow", "Batsman (BAT)")) self.WK.setText(_translate("MainWindow", "##")) self.label_4.setText(_translate("MainWindow", "Bowlers (BOW)")) self.label_10.setText(_translate("MainWindow", "AllRounders (AR) ")) self.ARL.setText(_translate("MainWindow", "##")) self.BOWL.setText(_translate("MainWindow", "##")) self.label_12.setText(_translate("MainWindow", "Wicket-Keeper (WK)")) self.label.setText(_translate("MainWindow", "Your Selection")) self.label_6.setText(_translate("MainWindow", "Points Availables")) self.points_available.setText(_translate("MainWindow", "####")) self.label_7.setText(_translate("MainWindow", "Points Used")) self.points_used.setText(_translate("MainWindow", "####")) self.bat_rb.setText(_translate("MainWindow", "BAT")) self.bow_rb.setText(_translate("MainWindow", "BOW")) self.ar_rb.setText(_translate("MainWindow", "AR")) self.wk_rb.setText(_translate("MainWindow", "WK")) self.label_9.setText(_translate("MainWindow", ">")) self.label_8.setText(_translate("MainWindow", "Team Name :")) self.team_name.setText(_translate("MainWindow", "Displayed Here")) self.menuManage_Teams.setTitle(_translate("MainWindow", "Manage Teams")) self.new_t.setText(_translate("MainWindow", "NEW Team")) self.new_t.setShortcut(_translate("MainWindow", "Ctrl+N")) self.open_t.setText(_translate("MainWindow", "OPEN Team")) self.open_t.setShortcut(_translate("MainWindow", "Ctrl+O")) self.save_t.setText(_translate("MainWindow", "SAVE team")) self.save_t.setShortcut(_translate("MainWindow", "Ctrl+S")) self.evaluate_t.setText(_translate("MainWindow", "EVALUATE Team")) self.evaluate_t.setShortcut(_translate("MainWindow", "Ctrl+E")) self.actionQuit.setText(_translate("MainWindow", "QUIT")) # NEW FILE MENU def file_new(self): self.newDialog.show() def namechange(self): teamname = self.new_screen.team_name.text() fantcurs.execute("SELECT DISTINCT name FROM teams") l = fantcurs.fetchall() for i in l: if i[0] == teamname: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Information) msg.setText( "Team with same name already exists!!\nPlease choose another name" ) msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 if len(teamname) == 0: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("You cannot leave the field blank!!!") msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 elif teamname.isnumeric(): msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText( "Please enter a valid teamname\n(Name must contain atleast one character)!!" ) msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 else: self.reset() self.tname = self.new_screen.team_name.text() self.team_name.setText(str(' ' + self.tname)) self.newDialog.close() #TO RESET ALL COUNTS AND LITS def reset(self): self.enablebuttons() self.load_names() self.used_points = 0 self.alrdscount = 0 self.wicketerscount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.totalcount = 0 self.avail_points = 1000 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) self.list1.clear() self.load_names() self.sel_player.clear() #SAVE TEAM MENU def file_save(self): if not self.error(): #IF THERE IS AN ERROR msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' Inufficient Players OR Points !!') msg.setWindowTitle("Fantasy Cricket") msg.exec_() elif self.error(): # IF NO ERROR try: fantcurs.execute("SELECT DISTINCT name FROM teams;") x = fantcurs.fetchall() for i in x: if self.team_name.text( ) == i[0]: # CHECKING IF THE TEAMNAME ALREADY EXISTS print('Updating already there') fantcurs.execute("DELETE FROM teams WHERE name='" + self.team_name.text() + "';") #DELETING TO UPDATE TEAM except: print('error') for i in range(self.sel_player.count()): # print('----addding--') # print('teamnane: ',self.team_name.text()) # print('playername: ',self.list1[i]) # print('points: ', player_points[self.list1[i]]) try: fantcurs.execute( "INSERT INTO teams (name,players,value) VALUES (?,?,?)", (self.team_name.text(), self.list1[i], player_points[self.list1[i]])) # self.file_evaluate() except: print('error in operation!') fant.commit() else: print('---error in operation') # QUITING METHOD def quit(self): msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' Bye Bye') msg.setWindowTitle("Fantasy Cricket") msg.exec_() # print('exit') sys.exit() #ON RADIOBUTTONS CLICKED def load_names(self): Batsman = 'BAT' WicketKeeper = 'WK' Allrounder = 'AR' Bowler = 'BWL' sql1 = "SELECT player,value from stats WHERE ctg = '" + Batsman + "';" sql2 = "SELECT Player,value from stats WHERE ctg = '" + WicketKeeper + "';" sql3 = "SELECT Player,value from stats WHERE ctg ='" + Allrounder + "';" sql4 = "SELECT Player,value from stats WHERE ctg = '" + Bowler + "';" fantcurs.execute(sql1) x = fantcurs.fetchall() fantcurs.execute(sql4) y = fantcurs.fetchall() fantcurs.execute(sql3) z = fantcurs.fetchall() fantcurs.execute(sql2) w = fantcurs.fetchall() batsmen = [] bowlers = [] allrounders = [] wcktkeepers = [] for k in x: batsmen.append(k[0]) self.b.append(k[0]) self.stats[k[0]] = k[1] for k in y: bowlers.append(k[0]) self.stats[k[0]] = k[1] self.a.append(k[0]) for k in w: wcktkeepers.append(k[0]) self.stats[k[0]] = k[1] self.d.append(k[0]) for k in z: allrounders.append(k[0]) self.stats[k[0]] = k[1] self.c.append(k[0]) for i in self.list1: if i in allrounders: allrounders.remove(i) elif i in batsmen: batsmen.remove(i) elif i in bowlers: bowlers.remove(i) elif i in wcktkeepers: wcktkeepers.remove(i) if self.bat_rb.isChecked() == True: self.av_player.clear() for i in range(len(batsmen)): item = QtWidgets.QListWidgetItem(batsmen[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.bow_rb.isChecked() == True: self.av_player.clear() for i in range(len(bowlers)): item = QtWidgets.QListWidgetItem(bowlers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.ar_rb.isChecked() == True: self.av_player.clear() for i in range(len(allrounders)): item = QtWidgets.QListWidgetItem(allrounders[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.wk_rb.isChecked() == True: self.av_player.clear() for i in range(len(wcktkeepers)): item = QtWidgets.QListWidgetItem(wcktkeepers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) def removelist1( self, item): # REMOVE FROM AVAILABLE PLAYERS AND ADD TO SELECTED PLAYERS self.conditions_1(item.text()) self.av_player.takeItem(self.av_player.row(item)) self.sel_player.addItem(item.text()) self.totalcount = self.sel_player.count() self.list1.append(item.text()) self.error() def conditions_1( self, cat ): # Adding and Deducting respective points from points_calculator.py self.avail_points -= self.stats[cat] self.used_points += self.stats[cat] if cat in self.a: self.bowlerscount += 1 elif cat in self.d: self.wicketerscount += 1 elif cat in self.c: self.alrdscount += 1 elif cat in self.b: self.batsmencount += 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) def conditions_2( self, cat ): # Adding and Deducting respective poinrs from points_calculator.py self.avail_points += self.stats[cat] self.used_points -= self.stats[cat] if cat in self.a: self.bowlerscount -= 1 elif cat in self.d: self.wicketerscount -= 1 elif cat in self.c: self.alrdscount -= 1 elif cat in self.b: self.batsmencount -= 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) def removelist2( self, item): # REMOVE FROM SELECTED PLAYERS AND ADD TO AVAIALBLE PLAYERS self.sel_player.takeItem(self.sel_player.row(item)) self.av_player.addItem(item.text()) self.list1.remove(item.text()) # self.error() self.totalcount = self.sel_player.count() self.conditions_2(item.text()) def openteam(self): #upon open team selected self.reset() teamname = self.open_screen.open_cb.currentText() self.team_name.setText(teamname) self.enablebuttons() fantcurs.execute("SELECT players from teams WHERE name= '" + teamname + "';") x = fantcurs.fetchall() score = [] for i in x: fantcurs.execute("SELECT value from stats WHERE player='" + i[0] + "';") y = fantcurs.fetchone() score.append(y[0]) # print(score) sum = 0 for i in score: sum += i self.sel_player.clear() self.load_names() for i in x: self.sel_player.addItem(i[0]) self.list1.append(i[0]) self.conditions_1(i[0]) self.used_points = sum self.avail_points = 1000 - sum self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.openDialog.close() def enablebuttons(self): self.bat_rb.setEnabled(True) self.bow_rb.setEnabled(True) self.ar_rb.setEnabled(True) self.wk_rb.setEnabled(True) def disablebuttons(self): self.bat_rb.setEnabled(False) self.bow_rb.setEnabled(False) self.ar_rb.setEnabled(False) self.wk_rb.setEnabled(False) def error(self): msg = QMessageBox() if self.wicketerscount > 1: msg.setIcon(QMessageBox.Critical) # msg.setText("Error") msg.setInformativeText('Only 1 wicketkeeper is allowed!') msg.setWindowTitle("Error") msg.exec_() return 0 elif self.totalcount > 11: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('No more than 11 players allowed!') msg.setWindowTitle("Selection Error") msg.exec_() return 0 elif self.totalcount < 11: return 0 elif self.wicketerscount < 1: return 0 elif self.avail_points <= -1: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('Not enough points!') msg.setWindowTitle("Selection Cricket") msg.exec_() return 0 return 1
class Ui_MainWindow(object): def __init__(self): self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog) # FILE OPENING TAB def file_open(self): self.open_screen.setupUi(self.openDialog) self.openDialog.show() self.open_screen.openbtn.clicked.connect(self.openteam) # EVALUATE TEAM TAB def file_evaluate(self): self.eval_screen.setupUi(self.EvaluateWindow) self.EvaluateWindow.show() def setupUi(self, MainWindow): # INITIALISING POINTS AND COUNTS self.avail_points = 1000 self.used_points = 0 self.totalcount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.alrdscount = 0 self.wicketerscount = 0 # INITIALIZING CATEGORY self.a = [] # bowler names list self.b = [] # batsman nameslist self.c = [] # allrounder names list self.d = [] #wicketer names list self.list1 = [] # selected player's list MainWindow.setObjectName("MainWindow") MainWindow.resize(737, 728) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) MainWindow.setFont(font) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.verticalLayout = QtWidgets.QVBoxLayout(self.centralwidget) self.verticalLayout.setObjectName("verticalLayout") self.team_name = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(16) font.setBold(True) font.setItalic(False) font.setWeight(75) # TEAMNAME self.team_name.setFont(font) self.team_name.setStyleSheet("") self.team_name.setObjectName("team_name") self.verticalLayout.addWidget(self.team_name) self.line = QtWidgets.QFrame(self.centralwidget) self.line.setFrameShape(QtWidgets.QFrame.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Sunken) self.line.setObjectName("line") self.verticalLayout.addWidget(self.line) self.horizontalLayout = QtWidgets.QHBoxLayout() self.horizontalLayout.setSizeConstraint( QtWidgets.QLayout.SetNoConstraint) self.horizontalLayout.setContentsMargins(-1, 20, -1, 20) self.horizontalLayout.setSpacing(0) self.horizontalLayout.setObjectName("horizontalLayout") self.Batsman = QtWidgets.QLabel(self.centralwidget) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) self.Batsman.setPalette(palette) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.Batsman.setFont(font) self.Batsman.setIndent(1) self.Batsman.setObjectName("Batsman") self.horizontalLayout.addWidget(self.Batsman) #BATSMAN COUNT self.batcount = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.batcount.setFont(font) self.batcount.setObjectName("batcount") self.horizontalLayout.addWidget(self.batcount) self.Wicketkeeepr = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.Wicketkeeepr.setFont(font) self.Wicketkeeepr.setObjectName("Wicketkeeepr") self.horizontalLayout.addWidget(self.Wicketkeeepr) # WICKETER'S COUNT self.wicketcount = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.wicketcount.setFont(font) self.wicketcount.setIndent(10) self.wicketcount.setObjectName("wicketcount") self.horizontalLayout.addWidget(self.wicketcount) self.Allrounder = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.Allrounder.setFont(font) self.Allrounder.setObjectName("Allrounder") self.horizontalLayout.addWidget(self.Allrounder) # ALLROUNDER'S COUNT self.alrcount = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.alrcount.setFont(font) self.alrcount.setIndent(10) self.alrcount.setObjectName("alrcount") self.horizontalLayout.addWidget(self.alrcount) self.Bowlers = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.Bowlers.setFont(font) self.Bowlers.setObjectName("Bowlers") self.horizontalLayout.addWidget(self.Bowlers) #BOWLERS COUNT self.bowlcount = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.bowlcount.setFont(font) self.bowlcount.setIndent(10) self.bowlcount.setObjectName("bowlcount") self.horizontalLayout.addWidget(self.bowlcount) self.verticalLayout.addLayout(self.horizontalLayout) self.line_2 = QtWidgets.QFrame(self.centralwidget) self.line_2.setFrameShape(QtWidgets.QFrame.HLine) self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_2.setObjectName("line_2") self.verticalLayout.addWidget(self.line_2) self.horizontalLayout_3 = QtWidgets.QHBoxLayout() self.horizontalLayout_3.setSizeConstraint( QtWidgets.QLayout.SetMaximumSize) self.horizontalLayout_3.setContentsMargins(0, 20, -1, 20) self.horizontalLayout_3.setSpacing(0) self.horizontalLayout_3.setObjectName("horizontalLayout_3") # RADIOBUTTONS FOR CHOOSING CATEGORY # BAT RB self.bat_rb = QtWidgets.QRadioButton(self.centralwidget) self.bat_rb.setEnabled(False) font = QtGui.QFont() font.setPointSize(9) font.setBold(True) font.setWeight(75) self.bat_rb.setFont(font) self.bat_rb.setTabletTracking(False) self.bat_rb.setAcceptDrops(False) self.bat_rb.setToolTipDuration(20) self.bat_rb.setStyleSheet("Batmans") self.bat_rb.setObjectName("bat_rb") self.horizontalLayout_3.addWidget(self.bat_rb) # WK RB self.wk_rb = QtWidgets.QRadioButton(self.centralwidget) self.wk_rb.setEnabled(False) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.wk_rb.setFont(font) self.wk_rb.setObjectName("wk_rb") self.horizontalLayout_3.addWidget(self.wk_rb) # ALLROUUNDER RB self.ar_rb = QtWidgets.QRadioButton(self.centralwidget) self.ar_rb.setEnabled(False) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.ar_rb.setFont(font) self.ar_rb.setChecked(False) self.ar_rb.setObjectName("ar_rb") self.horizontalLayout_3.addWidget(self.ar_rb) # BOWLER RB self.bow_rb = QtWidgets.QRadioButton(self.centralwidget) self.bow_rb.setEnabled(False) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.bow_rb.setFont(font) self.bow_rb.setObjectName("bow_rb") self.horizontalLayout_3.addWidget(self.bow_rb) self.verticalLayout.addLayout(self.horizontalLayout_3) self.line_3 = QtWidgets.QFrame(self.centralwidget) self.line_3.setFrameShape(QtWidgets.QFrame.HLine) self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_3.setObjectName("line_3") self.verticalLayout.addWidget(self.line_3) self.label = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.label.setFont(font) self.label.setText("") self.label.setObjectName("label") self.verticalLayout.addWidget(self.label) self.horizontalLayout_5 = QtWidgets.QHBoxLayout() self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.Totalplayers = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.Totalplayers.setFont(font) self.Totalplayers.setIndent(30) self.Totalplayers.setObjectName("Totalplayers") self.horizontalLayout_5.addWidget(self.Totalplayers) #POINTS CALCULATION #POINTS AVAILABLE self.points_available = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.points_available.setFont(font) self.points_available.setIndent(-10) self.points_available.setObjectName("points_available") self.horizontalLayout_5.addWidget(self.points_available) self.TeamName = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.TeamName.setFont(font) self.TeamName.setIndent(100) self.TeamName.setObjectName("TeamName") self.horizontalLayout_5.addWidget(self.TeamName) # POINTS USED self.points_used = QtWidgets.QLabel(self.centralwidget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.points_used.setFont(font) self.points_used.setIndent(60) self.points_used.setObjectName("points_used") self.horizontalLayout_5.addWidget(self.points_used) self.verticalLayout.addLayout(self.horizontalLayout_5) self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setMaximumSize(QtCore.QSize(778, 16)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(75) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.verticalLayout.addWidget(self.label_2) self.Team = QtWidgets.QHBoxLayout() self.Team.setObjectName("Team") # PLAYER'S LISTWIDGET #AVAILABLE PLAYERS LISTWIDGET self.availplayers_lw = QtWidgets.QListWidget(self.centralwidget) self.availplayers_lw.setStyleSheet( "color: rgb(3, 190, 159);background-color: rgb(240, 240, 240);") self.availplayers_lw.setObjectName("availplayers_lw") self.Team.addWidget(self.availplayers_lw) self.selectedplayers_lw = QtWidgets.QListWidget(self.centralwidget) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0, 128)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.PlaceholderText, brush) #SELECTED PLAYER'S LISTWIDGET self.selectedplayers_lw.setPalette(palette) self.selectedplayers_lw.setStyleSheet( "color: rgb(3, 190, 159);background-color: rgb(240, 240, 240);") self.selectedplayers_lw.setObjectName("selectedplayers_lw") self.Team.addWidget(self.selectedplayers_lw) self.verticalLayout.addLayout(self.Team) MainWindow.setCentralWidget(self.centralwidget) #MENUBAR self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 737, 23)) self.menubar.setObjectName("menubar") self.menuManage_Teams = QtWidgets.QMenu(self.menubar) self.menuManage_Teams.setObjectName("menuManage_Teams") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) #NEW_TEAM self.new_team = QtWidgets.QAction(MainWindow) self.new_team.setShortcut("Ctrl+N") self.new_team.triggered.connect(self.file_new) self.new_team.setShortcutVisibleInContextMenu(True) self.new_team.setObjectName("new_team") #OPEN_TEAM self.open_team = QtWidgets.QAction(MainWindow) self.open_team.setShortcut("Ctrl+O") self.open_team.triggered.connect(self.file_open) self.open_team.setShortcutVisibleInContextMenu(True) self.open_team.setObjectName("open_team") # SAVE_TEAM self.save_team = QtWidgets.QAction(MainWindow) self.save_team.setShortcut("Ctrl+S") self.save_team.triggered.connect(self.file_save) self.save_team.setShortcutVisibleInContextMenu(True) self.save_team.setObjectName("save_team") #EVALUATE_TEAM self.evaluate_team = QtWidgets.QAction(MainWindow) self.evaluate_team.setShortcut("Ctrl+E") self.evaluate_team.triggered.connect(self.file_evaluate) self.evaluate_team.setShortcutVisibleInContextMenu(True) self.evaluate_team.setObjectName("evaluate_team") #QUIT_WINDOW self.actionQuit = QtWidgets.QAction(MainWindow) self.actionQuit.setObjectName("actionQuit") self.actionQuit.triggered.connect(self.quit) self.menuManage_Teams.addAction(self.new_team) self.menuManage_Teams.addAction(self.open_team) self.menuManage_Teams.addAction(self.evaluate_team) self.menuManage_Teams.addAction(self.save_team) self.menuManage_Teams.addAction(self.actionQuit) self.menubar.addAction(self.menuManage_Teams.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) # DOUBLE CLICK self.availplayers_lw.itemDoubleClicked.connect(self.removelist1) self.selectedplayers_lw.itemDoubleClicked.connect(self.removelist2) # --statistics of players self.stats = {} self.new_screen.savename.clicked.connect(self.namechange) # RADIOBUTTONS CLICK self.bat_rb.clicked.connect(self.load_names) self.wk_rb.clicked.connect(self.load_names) self.bow_rb.clicked.connect(self.load_names) self.ar_rb.clicked.connect(self.load_names) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.team_name.setText( _translate("MainWindow", " TEAM NAME ")) self.Batsman.setText(_translate("MainWindow", "Batsman(Bat)")) self.batcount.setText(_translate("MainWindow", "##")) self.Wicketkeeepr.setText(_translate("MainWindow", "WicketKeeper(WK)")) self.wicketcount.setText(_translate("MainWindow", "##")) self.Allrounder.setText(_translate("MainWindow", "Allrounder (ALR)")) self.alrcount.setText(_translate("MainWindow", "##")) self.Bowlers.setText(_translate("MainWindow", "Bowlers (Bowl)")) self.bowlcount.setText(_translate("MainWindow", "##")) self.bat_rb.setText(_translate("MainWindow", "Batsman")) self.wk_rb.setText(_translate("MainWindow", "WicketKeeper")) self.ar_rb.setText(_translate("MainWindow", "AllRounder")) self.bow_rb.setText(_translate("MainWindow", "Bowlers")) self.Totalplayers.setText(_translate("MainWindow", "available points ")) self.points_available.setStatusTip( _translate("MainWindow", "max point=100")) self.points_available.setText(_translate("MainWindow", "00")) self.TeamName.setText(_translate("MainWindow", "used points")) self.points_used.setText(_translate("MainWindow", "00")) self.label_2.setText( _translate( "MainWindow", " Available Players selected players" )) self.menuManage_Teams.setTitle(_translate("MainWindow", "Manage Teams")) self.new_team.setText(_translate("MainWindow", "New Team")) self.new_team.setStatusTip(_translate("MainWindow", "enter team name")) self.new_team.setShortcut(_translate("MainWindow", "Ctrl+N")) self.open_team.setText(_translate("MainWindow", "Open Team")) self.open_team.setStatusTip(_translate("MainWindow", "opening team")) self.open_team.setShortcut(_translate("MainWindow", "Ctrl+O")) self.save_team.setText(_translate("MainWindow", "Save Team")) self.save_team.setStatusTip(_translate("MainWindow", "saving team..")) self.save_team.setShortcut(_translate("MainWindow", "Ctrl+S")) self.evaluate_team.setText(_translate("MainWindow", "Evaluate Team")) self.evaluate_team.setShortcut(_translate("MainWindow", "Ctrl+E")) self.actionQuit.setText(_translate("MainWindow", "Quit")) # NEW FILE MENU def file_new(self): self.newDialog.show() def namechange(self): teamname = self.new_screen.team_name.text() fantcurs.execute("SELECT DISTINCT name FROM teams") l = fantcurs.fetchall() for i in l: if i[0] == teamname: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Information) msg.setText( "Team with same name already exists!!\nPlease choose another name" ) msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 if len(teamname) == 0: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("You cannot leave the field blank!!!") msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 elif teamname.isnumeric(): msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText( "Please enter a valid teamname\n(Name must contain atleast one character)!!" ) msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 else: self.reset() self.tname = self.new_screen.team_name.text() self.team_name.setText(' ' + self.tname) self.newDialog.close() #TO RESET ALL COUNTS AND LISTS def reset(self): self.enablebuttons() self.load_names() self.used_points = 0 self.alrdscount = 0 self.wicketerscount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.totalcount = 0 self.avail_points = 1000 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) self.list1.clear() self.load_names() self.selectedplayers_lw.clear() #SAVE TEAM MENU def file_save(self): if not self.error(): #IF THERE IS AN ERROR msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' 😪Insufficient Players OR Points !!') msg.setWindowTitle("Fantasy Cricket") msg.exec_() elif self.error(): # IF NO ERROR try: fantcurs.execute("SELECT DISTINCT name FROM teams;") x = fantcurs.fetchall() for i in x: if self.team_name.text( ) == i[0]: # CHECKING IF THE TEAMNAME ALREADY EXISTS print('Updating already there') fantcurs.execute("DELETE FROM teams WHERE name='" + self.team_name.text() + "';") #DELETING TO UPDATE TEAM except: print('error') for i in range(self.selectedplayers_lw.count()): # print('----addding--') # print('teamnane: ',self.team_name.text()) # print('playername: ',self.list1[i]) # print('points: ', player_points[self.list1[i]]) try: fantcurs.execute( "INSERT INTO teams (name,players,value) VALUES (?,?,?)", (self.team_name.text(), self.list1[i], player_points[self.list1[i]])) # self.file_evaluate() except: print('error in operation!') fant.commit() else: print('---error in operation') # QUITING METHOD def quit(self): msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' Bye 😙') msg.setWindowTitle("Fantasy Cricket") msg.exec_() # print('exit') sys.exit() #ON RADIOBUTTONS CLICKED def load_names(self): Batsman = 'BAT' WicketKeeper = 'WK' Allrounder = 'AR' Bowler = 'BWL' sql1 = "SELECT player,value from stats WHERE ctg = '" + Batsman + "';" sql2 = "SELECT Player,value from stats WHERE ctg = '" + WicketKeeper + "';" sql3 = "SELECT Player,value from stats WHERE ctg ='" + Allrounder + "';" sql4 = "SELECT Player,value from stats WHERE ctg = '" + Bowler + "';" fantcurs.execute(sql1) x = fantcurs.fetchall() fantcurs.execute(sql4) y = fantcurs.fetchall() fantcurs.execute(sql3) z = fantcurs.fetchall() fantcurs.execute(sql2) w = fantcurs.fetchall() batsmen = [] bowlers = [] allrounders = [] wcktkeepers = [] for k in x: batsmen.append(k[0]) self.b.append(k[0]) self.stats[k[0]] = k[1] for k in y: bowlers.append(k[0]) self.stats[k[0]] = k[1] self.a.append(k[0]) for k in w: wcktkeepers.append(k[0]) self.stats[k[0]] = k[1] self.d.append(k[0]) for k in z: allrounders.append(k[0]) self.stats[k[0]] = k[1] self.c.append(k[0]) for i in self.list1: if i in allrounders: allrounders.remove(i) elif i in batsmen: batsmen.remove(i) elif i in bowlers: bowlers.remove(i) elif i in wcktkeepers: wcktkeepers.remove(i) if self.bat_rb.isChecked() == True: self.availplayers_lw.clear() for i in range(len(batsmen)): item = QtWidgets.QListWidgetItem(batsmen[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.availplayers_lw.addItem(item) elif self.bow_rb.isChecked() == True: self.availplayers_lw.clear() for i in range(len(bowlers)): item = QtWidgets.QListWidgetItem(bowlers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.availplayers_lw.addItem(item) elif self.ar_rb.isChecked() == True: self.availplayers_lw.clear() for i in range(len(allrounders)): item = QtWidgets.QListWidgetItem(allrounders[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.availplayers_lw.addItem(item) elif self.wk_rb.isChecked() == True: self.availplayers_lw.clear() for i in range(len(wcktkeepers)): item = QtWidgets.QListWidgetItem(wcktkeepers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.availplayers_lw.addItem(item) def removelist1( self, item): # REMOVE FROM AVAILABLE PLAYERS AND ADD TO SELECTED PLAYERS self.conditions_1(item.text()) self.availplayers_lw.takeItem(self.availplayers_lw.row(item)) self.selectedplayers_lw.addItem(item.text()) self.totalcount = self.selectedplayers_lw.count() self.list1.append(item.text()) self.error() def conditions_1( self, cat ): # Adding and Deducting respective points from points_calculator.py self.avail_points -= self.stats[cat] self.used_points += self.stats[cat] if cat in self.a: self.bowlerscount += 1 elif cat in self.d: self.wicketerscount += 1 elif cat in self.c: self.alrdscount += 1 elif cat in self.b: self.batsmencount += 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) def conditions_2( self, cat ): # Adding and Deducting respective poinrs from points_calculator.py self.avail_points += self.stats[cat] self.used_points -= self.stats[cat] if cat in self.a: self.bowlerscount -= 1 elif cat in self.d: self.wicketerscount -= 1 elif cat in self.c: self.alrdscount -= 1 elif cat in self.b: self.batsmencount -= 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) def removelist2( self, item): # REMOVE FROM SELECTED PLAYERS AND ADD TO AVAIALBLE PLAYERS self.selectedplayers_lw.takeItem(self.selectedplayers_lw.row(item)) self.availplayers_lw.addItem(item.text()) self.list1.remove(item.text()) # self.error() self.totalcount = self.selectedplayers_lw.count() self.conditions_2(item.text()) def openteam(self): #upon open team selected self.reset() teamname = self.open_screen.open_cb.currentText() self.team_name.setText(teamname) self.enablebuttons() fantcurs.execute("SELECT players from teams WHERE name= '" + teamname + "';") x = fantcurs.fetchall() score = [] for i in x: fantcurs.execute("SELECT value from stats WHERE player='" + i[0] + "';") y = fantcurs.fetchone() score.append(y[0]) # print(score) sum = 0 for i in score: sum += i self.selectedplayers_lw.clear() self.load_names() for i in x: self.selectedplayers_lw.addItem(i[0]) self.list1.append(i[0]) self.conditions_1(i[0]) self.used_points = sum self.avail_points = 1000 - sum self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.openDialog.close() def enablebuttons(self): self.bat_rb.setEnabled(True) self.bow_rb.setEnabled(True) self.ar_rb.setEnabled(True) self.wk_rb.setEnabled(True) def error(self): msg = QMessageBox() if self.wicketerscount > 1: msg.setIcon(QMessageBox.Critical) # msg.setText("Error") msg.setInformativeText('Only 1 wicketkeeper is allowed!') msg.setWindowTitle("Error") msg.exec_() return 0 elif self.totalcount > 11: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('No more than 11 players allowed!') msg.setWindowTitle("Selection Error") msg.exec_() return 0 elif self.totalcount < 11: return 0 elif self.wicketerscount < 1: return 0 elif self.avail_points <= -1: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('Not enough points!') msg.setWindowTitle("Selection Cricket") msg.exec_() return 0 return 1
class Ui_MainWindow(object): def __init__(self): # linking files and creating objects self.new_Window = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.new_Window) self.evaluate_Window = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.evaluate_Window) self.open_Window = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.open_Window) def setupUi(self, MainWindow): #Ui setup # local variables self.avail_points = 1000 self.used_points = 0 self.totalcount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.alrdscount = 0 self.wicketerscount = 0 self.a = [] # bowler names list self.b = [] # batsman nameslist self.c = [] # allrounder names list self.d = [] #wicketer names list self.selectlist = [] # selectedplayer's list MainWindow.setObjectName("MainWindow") MainWindow.resize(789, 728) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(170, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(127, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) MainWindow.setPalette(palette) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(69) MainWindow.setFont(font) self.centralwidget = QtWidgets.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") self.team_name = QtWidgets.QLabel(self.centralwidget) self.team_name.setGeometry(QtCore.QRect(620, 230, 91, 25)) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setPointSize(12) font.setBold(True) font.setItalic(False) font.setWeight(69) self.team_name.setFont(font) self.team_name.setStyleSheet("") self.team_name.setObjectName("team_name") self.line = QtWidgets.QFrame(self.centralwidget) self.line.setGeometry(QtCore.QRect(9, 40, 769, 16)) self.line.setFrameShape(QtWidgets.QFrame.HLine) self.line.setFrameShadow(QtWidgets.QFrame.Sunken) self.line.setObjectName("line") self.line_2 = QtWidgets.QFrame(self.centralwidget) self.line_2.setGeometry(QtCore.QRect(9, 134, 769, 16)) self.line_2.setFrameShape(QtWidgets.QFrame.HLine) self.line_2.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_2.setObjectName("line_2") self.line_3 = QtWidgets.QFrame(self.centralwidget) self.line_3.setGeometry(QtCore.QRect(9, 210, 769, 16)) self.line_3.setFrameShape(QtWidgets.QFrame.HLine) self.line_3.setFrameShadow(QtWidgets.QFrame.Sunken) self.line_3.setObjectName("line_3") self.label = QtWidgets.QLabel(self.centralwidget) self.label.setGeometry(QtCore.QRect(9, 219, 16, 16)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(9) font.setBold(True) font.setItalic(True) font.setWeight(69) self.label.setFont(font) self.label.setText("") self.label.setObjectName("label") self.widget = QtWidgets.QWidget(self.centralwidget) self.widget.setGeometry(QtCore.QRect(10, 160, 761, 41)) self.widget.setObjectName("widget") self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.widget) self.horizontalLayout_5.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint) self.horizontalLayout_5.setContentsMargins(0, 0, 0, 0) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.Totalplayers = QtWidgets.QLabel(self.widget) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(11) font.setBold(True) font.setItalic(False) font.setWeight(69) self.Totalplayers.setFont(font) self.Totalplayers.setIndent(30) self.Totalplayers.setObjectName("Totalplayers") self.horizontalLayout_5.addWidget(self.Totalplayers) self.points_available = QtWidgets.QLabel(self.widget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(11) font.setBold(True) font.setItalic(True) font.setWeight(69) self.points_available.setFont(font) self.points_available.setIndent(-10) self.points_available.setObjectName("points_available") self.horizontalLayout_5.addWidget(self.points_available) self.TeamName = QtWidgets.QLabel(self.widget) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(11) font.setBold(True) font.setItalic(False) font.setWeight(69) self.TeamName.setFont(font) self.TeamName.setIndent(100) self.TeamName.setObjectName("TeamName") self.horizontalLayout_5.addWidget(self.TeamName) self.points_used = QtWidgets.QLabel(self.widget) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(11) font.setBold(True) font.setItalic(True) font.setWeight(69) self.points_used.setFont(font) self.points_used.setIndent(60) self.points_used.setObjectName("points_used") self.horizontalLayout_5.addWidget(self.points_used) self.label_2 = QtWidgets.QLabel(self.centralwidget) self.label_2.setGeometry(QtCore.QRect(480, 220, 131, 41)) font = QtGui.QFont() font.setPointSize(13) font.setItalic(False) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.label_3 = QtWidgets.QLabel(self.centralwidget) self.label_3.setGeometry(QtCore.QRect(16, 259, 211, 31)) self.label_3.setObjectName("label_3") self.label_4 = QtWidgets.QLabel(self.centralwidget) self.label_4.setGeometry(QtCore.QRect(400, 260, 211, 31)) self.label_4.setObjectName("label_4") self.label_5 = QtWidgets.QLabel(self.centralwidget) self.label_5.setGeometry(QtCore.QRect(40, 10, 711, 31)) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.label_5.sizePolicy().hasHeightForWidth()) self.label_5.setSizePolicy(sizePolicy) font = QtGui.QFont() font.setPointSize(16) font.setItalic(False) self.label_5.setFont(font) self.label_5.setFrameShape(QtWidgets.QFrame.Box) self.label_5.setAlignment(QtCore.Qt.AlignCenter) self.label_5.setObjectName("label_5") self.availablelist = QtWidgets.QListWidget(self.centralwidget) self.availablelist.setGeometry(QtCore.QRect(10, 290, 361, 381)) self.availablelist.setStyleSheet("color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);") self.availablelist.setObjectName("availablelist") self.selectedlist = QtWidgets.QListWidget(self.centralwidget) self.selectedlist.setGeometry(QtCore.QRect(390, 290, 381, 381)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(212, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(85, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(113, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(212, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(212, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(85, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(113, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(212, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(212, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(85, 127, 127)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(113, 170, 170)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(3, 190, 159)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(240, 240, 240)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(170, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) self.selectedlist.setPalette(palette) self.selectedlist.setStyleSheet("color: rgb(0, 0, 0);background-color: rgb(240, 240, 240);") self.selectedlist.setObjectName("selectedlist") self.batradio = QtWidgets.QRadioButton(self.centralwidget) self.batradio.setEnabled(False) self.batradio.setGeometry(QtCore.QRect(10, 240, 69, 21)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(9) font.setBold(True) font.setWeight(69) self.batradio.setFont(font) self.batradio.setTabletTracking(False) self.batradio.setAcceptDrops(False) self.batradio.setToolTipDuration(20) self.batradio.setStyleSheet("Batmans") self.batradio.setObjectName("batradio") self.wkradio = QtWidgets.QRadioButton(self.centralwidget) self.wkradio.setEnabled(False) self.wkradio.setGeometry(QtCore.QRect(70, 240, 120, 21)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(9) font.setBold(True) font.setItalic(False) font.setWeight(69) self.wkradio.setFont(font) self.wkradio.setObjectName("wkradio") self.arradio = QtWidgets.QRadioButton(self.centralwidget) self.arradio.setEnabled(False) self.arradio.setGeometry(QtCore.QRect(130, 240, 100, 21)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(9) font.setBold(True) font.setItalic(False) font.setWeight(69) self.arradio.setFont(font) self.arradio.setChecked(False) self.arradio.setObjectName("arradio") self.bowlradio = QtWidgets.QRadioButton(self.centralwidget) self.bowlradio.setEnabled(False) self.bowlradio.setGeometry(QtCore.QRect(200, 240, 79, 21)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(9) font.setBold(True) font.setItalic(False) font.setWeight(69) self.bowlradio.setFont(font) self.bowlradio.setObjectName("bowlradio") self.Batsman = QtWidgets.QLabel(self.centralwidget) self.Batsman.setGeometry(QtCore.QRect(10, 50, 126, 41)) palette = QtGui.QPalette() brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(233, 233, 233)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(141, 141, 141)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(233, 233, 233)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Active, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(233, 233, 233)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(141, 141, 141)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(233, 233, 233)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Inactive, QtGui.QPalette.ToolTipText, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.WindowText, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Button, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Light, brush) brush = QtGui.QBrush(QtGui.QColor(233, 233, 233)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Midlight, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Dark, brush) brush = QtGui.QBrush(QtGui.QColor(141, 141, 141)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Mid, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Text, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 255)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.BrightText, brush) brush = QtGui.QBrush(QtGui.QColor(106, 106, 106)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ButtonText, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Base, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Window, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.Shadow, brush) brush = QtGui.QBrush(QtGui.QColor(212, 212, 212)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.AlternateBase, brush) brush = QtGui.QBrush(QtGui.QColor(255, 255, 220)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipBase, brush) brush = QtGui.QBrush(QtGui.QColor(0, 0, 0)) brush.setStyle(QtCore.Qt.SolidPattern) palette.setBrush(QtGui.QPalette.Disabled, QtGui.QPalette.ToolTipText, brush) self.Batsman.setPalette(palette) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(10) font.setBold(True) font.setItalic(False) font.setWeight(69) self.Batsman.setFont(font) self.Batsman.setIndent(1) self.Batsman.setObjectName("Batsman") self.Bowlers = QtWidgets.QLabel(self.centralwidget) self.Bowlers.setGeometry(QtCore.QRect(370, 110, 110, 17)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(10) font.setBold(True) font.setItalic(False) font.setWeight(69) self.Bowlers.setFont(font) self.Bowlers.setObjectName("Bowlers") self.alrcount = QtWidgets.QLabel(self.centralwidget) self.alrcount.setGeometry(QtCore.QRect(500, 60, 31, 17)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(10) font.setBold(True) font.setItalic(True) font.setWeight(69) self.alrcount.setFont(font) self.alrcount.setIndent(10) self.alrcount.setObjectName("alrcount") self.bowlcount = QtWidgets.QLabel(self.centralwidget) self.bowlcount.setGeometry(QtCore.QRect(480, 110, 31, 17)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(10) font.setBold(True) font.setItalic(True) font.setWeight(69) self.bowlcount.setFont(font) self.bowlcount.setIndent(10) self.bowlcount.setObjectName("bowlcount") self.batcount = QtWidgets.QLabel(self.centralwidget) self.batcount.setGeometry(QtCore.QRect(130, 60, 21, 17)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(10) font.setBold(True) font.setItalic(True) font.setWeight(69) self.batcount.setFont(font) self.batcount.setObjectName("batcount") self.Allrounder = QtWidgets.QLabel(self.centralwidget) self.Allrounder.setGeometry(QtCore.QRect(370, 60, 123, 17)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(10) font.setBold(True) font.setItalic(False) font.setWeight(69) self.Allrounder.setFont(font) self.Allrounder.setObjectName("Allrounder") self.Wicketkeeepr = QtWidgets.QLabel(self.centralwidget) self.Wicketkeeepr.setGeometry(QtCore.QRect(20, 110, 139, 17)) font = QtGui.QFont() font.setFamily("Sans") font.setPointSize(10) font.setBold(True) font.setItalic(False) font.setWeight(69) self.Wicketkeeepr.setFont(font) self.Wicketkeeepr.setObjectName("Wicketkeeepr") self.wicketcount = QtWidgets.QLabel(self.centralwidget) self.wicketcount.setGeometry(QtCore.QRect(160, 110, 31, 17)) font = QtGui.QFont() font.setFamily("Bookman Old Style") font.setPointSize(10) font.setBold(True) font.setItalic(True) font.setWeight(69) self.wicketcount.setFont(font) self.wicketcount.setIndent(10) self.wicketcount.setObjectName("wicketcount") self.line.raise_() self.line_2.raise_() self.line_3.raise_() self.label.raise_() self.batradio.raise_() self.wkradio.raise_() self.arradio.raise_() self.bowlradio.raise_() self.label_2.raise_() self.label_3.raise_() self.label_4.raise_() self.label_5.raise_() self.team_name.raise_() MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 789, 20)) self.menubar.setObjectName("menubar") self.menuManage_Teams = QtWidgets.QMenu(self.menubar) font = QtGui.QFont() font.setFamily("Sans") font.setBold(True) font.setWeight(69) self.menuManage_Teams.setFont(font) self.menuManage_Teams.setObjectName("menuManage_Teams") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) self.new_team = QtWidgets.QAction(MainWindow) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setBold(False) font.setWeight(50) self.new_team.setFont(font) self.new_team.setProperty("shortcutVisibleInContextMenu", True) self.new_team.setObjectName("new_team") self.new_team.triggered.connect(self.file_new) self.open_team = QtWidgets.QAction(MainWindow) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setBold(False) font.setWeight(50) self.open_team.setFont(font) self.open_team.setProperty("shortcutVisibleInContextMenu", True) self.open_team.setObjectName("open_team") self.open_team.triggered.connect(self.open_file) self.save_team = QtWidgets.QAction(MainWindow) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setBold(False) font.setWeight(50) self.save_team.setFont(font) self.save_team.setProperty("shortcutVisibleInContextMenu", True) self.save_team.setObjectName("save_team") self.save_team.triggered.connect(self.file_save) self.evaluate_team = QtWidgets.QAction(MainWindow) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setBold(False) font.setWeight(50) self.evaluate_team.setFont(font) self.evaluate_team.setProperty("shortcutVisibleInContextMenu", True) self.evaluate_team.setObjectName("evaluate_team") self.evaluate_team.triggered.connect(self.eval_file) self.actionQuit = QtWidgets.QAction(MainWindow) font = QtGui.QFont() font.setFamily("DejaVu Sans") font.setBold(False) font.setWeight(50) self.actionQuit.setFont(font) self.actionQuit.setProperty("shortcutVisibleInContextMenu", True) self.actionQuit.setObjectName("actionQuit") self.actionQuit.triggered.connect(lambda: quit()) self.menuManage_Teams.addAction(self.new_team) self.menuManage_Teams.addAction(self.open_team) self.menuManage_Teams.addAction(self.evaluate_team) self.menuManage_Teams.addAction(self.save_team) self.menuManage_Teams.addAction(self.actionQuit) self.menubar.addAction(self.menuManage_Teams.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) # Click responses self.availablelist.itemDoubleClicked.connect(self.transfer1) self.selectedlist.itemDoubleClicked.connect(self.transfer2) self.stats = {} self.new_screen.savename.clicked.connect(self.namechange) self.batradio.clicked.connect(self.load_names) self.wkradio.clicked.connect(self.load_names) self.bowlradio.clicked.connect(self.load_names) self.arradio.clicked.connect(self.load_names) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.team_name.setText(_translate("MainWindow", "XXX")) self.Totalplayers.setText(_translate("MainWindow", "Available Points")) self.points_available.setStatusTip(_translate("MainWindow", "max point=100")) self.points_available.setText(_translate("MainWindow", "##")) self.TeamName.setText(_translate("MainWindow", "Points used")) self.points_used.setText(_translate("MainWindow", "##")) self.label_2.setText(_translate("MainWindow", "Team Name:")) self.label_3.setText(_translate("MainWindow", "Available Players")) self.label_4.setText(_translate("MainWindow", "Selected Players")) self.label_5.setText(_translate("MainWindow", "Welcome to Fantasy Cricket!")) self.batradio.setText(_translate("MainWindow", "Bat")) self.wkradio.setText(_translate("MainWindow", "WK")) self.arradio.setText(_translate("MainWindow", "AR")) self.bowlradio.setText(_translate("MainWindow", "BOWL")) self.Batsman.setText(_translate("MainWindow", "Batsman(Bat)")) self.Bowlers.setText(_translate("MainWindow", "Bowlers (Bowl)")) self.alrcount.setText(_translate("MainWindow", "##")) self.bowlcount.setText(_translate("MainWindow", "##")) self.batcount.setText(_translate("MainWindow", "##")) self.Allrounder.setText(_translate("MainWindow", "Allrounder (ALR)")) self.Wicketkeeepr.setText(_translate("MainWindow", "WicketKeeper(WK)")) self.wicketcount.setText(_translate("MainWindow", "##")) self.menuManage_Teams.setTitle(_translate("MainWindow", "Manage Teams")) self.new_team.setText(_translate("MainWindow", "New Team")) self.new_team.setStatusTip(_translate("MainWindow", "enter team name")) self.new_team.setShortcut(_translate("MainWindow", "Ctrl+N")) self.open_team.setText(_translate("MainWindow", "Open Team")) self.open_team.setStatusTip(_translate("MainWindow", "opening team")) self.open_team.setShortcut(_translate("MainWindow", "Ctrl+O")) self.save_team.setText(_translate("MainWindow", "Save Team")) self.save_team.setStatusTip(_translate("MainWindow", "saving team..")) self.save_team.setShortcut(_translate("MainWindow", "Ctrl+S")) self.evaluate_team.setText(_translate("MainWindow", "Evaluate Team")) self.evaluate_team.setShortcut(_translate("MainWindow", "Ctrl+E")) self.actionQuit.setText(_translate("MainWindow", "Quit")) self.actionQuit.setShortcut(_translate("MainWindow", "Ctrl+Q")) #Double Click functions: def transfer1(self, item):# available -> selected self.calculations_1(item.text()) self.availablelist.takeItem(self.availablelist.row(item)) self.selectedlist.addItem(item.text()) self.totalcount = self.selectedlist.count() self.selectlist.append(item.text()) self.checkerror() def transfer2(self, item):#available <- Selected self.selectedlist.takeItem(self.selectedlist.row(item)) self.availablelist.addItem(item.text()) self.selectlist.remove(item.text()) self.totalcount = self.selectedlist.count() self.calculations_2(item.text()) def calculations_1(self, cat): # update player and point count self.avail_points -= self.stats[cat] self.used_points += self.stats[cat] if cat in self.a: self.bowlerscount += 1 elif cat in self.d: self.wicketerscount += 1 elif cat in self.c: self.alrdscount += 1 elif cat in self.b: self.batsmencount += 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) def calculations_2(self, cat): # update player and point count self.avail_points += self.stats[cat] self.used_points -= self.stats[cat] if cat in self.a: self.bowlerscount -= 1 elif cat in self.d: self.wicketerscount -= 1 elif cat in self.c: self.alrdscount -= 1 elif cat in self.b: self.batsmencount -= 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) #Double click functions end #Menu Functions def file_new(self):# opens new.py self.new_Window.show() def open_file(self): # opens open file self.open_screen.setupUi(self.open_Window) self.open_Window.show() self.open_screen.openbtn.clicked.connect(self.openteam) def eval_file(self): # opens evaluate file self.eval_screen.setupUi(self.evaluate_Window) self.evaluate_Window.show() def namechange(self): # set name for team teamname = self.new_screen.team_name.text() datacurs.execute("SELECT DISTINCT name FROM teams") allteams = datacurs.fetchall() for oneteam in allteams: if oneteam[0] == teamname: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Information) msg.setText("Team name already exists, try something else") msg.setWindowTitle("Error") msg.exec_() return 0 if len(teamname) == 0: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("Team name cannot be empty") msg.setWindowTitle("Error") msg.exec_() return 0 elif teamname.isnumeric(): msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("Team name cannot be only numbers") msg.setWindowTitle("Error") msg.exec_() return 0 else: self.reset() self.tname = self.new_screen.team_name.text() self.team_name.setText(self.tname) self.new_Window.close() def file_save(self): # save teams, if already there -> update if not self.checkerror(): # if error msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText('Insufficient Players OR Points !!') msg.setWindowTitle('Error') msg.exec_() elif self.checkerror(): # if no error try: datacurs.execute("SELECT DISTINCT name FROM teams;") allteams = datacurs.fetchall() for oneteam in allteams: if self.team_name.text() == oneteam[0]: print('Updating already there') datacurs.execute("DELETE FROM teams WHERE name='" + self.team_name.text() + "';") except: print('error') for i in range(self.selectedlist.count()): try: datacurs.execute("INSERT INTO teams (name,players,value) VALUES (?,?,?)", (self.team_name.text(), self.selectlist[i], player_points[self.selectlist[i]])) except: print('error in operation!') data.commit() else: print('---error in operation') def openteam(self): # open saved teams self.reset() teamname = self.open_screen.opendrop.currentText() self.team_name.setText(teamname) self.enablebuttons() datacurs.execute("SELECT players from teams WHERE name= '" + teamname + "';") Players = datacurs.fetchall() scores = [] for Player in Players: datacurs.execute("SELECT value from stats WHERE player='"+Player[0]+"';") playval = datacurs.fetchone() scores.append(playval[0]) summ = 0 for score in scores: summ += score self.selectedlist.clear() self.load_names() for Player in Players: self.selectedlist.addItem(Player[0]) self.selectlist.append(Player[0]) self.calculations_1(Player[0]) self.used_points = summ self.avail_points = 1000 - summ self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.open_Window.close() #Menu functions end #Radio button functions: def enablebuttons(self):# enables radio buttons self.batradio.setEnabled(True) self.bowlradio.setEnabled(True) self.arradio.setEnabled(True) self.wkradio.setEnabled(True) def load_names(self): #when radio buttons clicked datacurs.execute('SELECT player,value from stats WHERE ctg = "BAT";') batter = datacurs.fetchall() datacurs.execute('SELECT Player,value from stats WHERE ctg = "WK";') wick = datacurs.fetchall() datacurs.execute('SELECT Player,value from stats WHERE ctg ="AR";') rounder = datacurs.fetchall() datacurs.execute('SELECT Player,value from stats WHERE ctg = "BWL";') bowlin = datacurs.fetchall() batsmen = [] bowlers = [] allrounders = [] wcktkeepers = [] for boo in bowlin: bowlers.append(boo[0]) self.stats[boo[0]] = boo[1] self.a.append(boo[0]) for batt in batter: batsmen.append(batt[0]) self.b.append(batt[0]) self.stats[batt[0]] = batt[1] for roun in rounder: allrounders.append(roun[0]) self.stats[roun[0]] = roun[1] self.c.append(roun[0]) for wic in wick: wcktkeepers.append(wic[0]) self.stats[wic[0]] = wic[1] self.d.append(wic[0]) for selected in self.selectlist: if selected in allrounders: allrounders.remove(selected) elif selected in batsmen: batsmen.remove(selected) elif selected in bowlers: bowlers.remove(selected) elif selected in wcktkeepers: wcktkeepers.remove(selected) if self.batradio.isChecked() == True: self.availablelist.clear() for i in range(len(batsmen)): item = QtWidgets.QListWidgetItem(batsmen[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(69) item.setFont(font) self.availablelist.addItem(item) elif self.bowlradio.isChecked() == True: self.availablelist.clear() for i in range(len(bowlers)): item = QtWidgets.QListWidgetItem(bowlers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(69) item.setFont(font) self.availablelist.addItem(item) elif self.arradio.isChecked() == True: self.availablelist.clear() for i in range(len(allrounders)): item = QtWidgets.QListWidgetItem(allrounders[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(69) item.setFont(font) self.availablelist.addItem(item) elif self.wkradio.isChecked() == True: self.availablelist.clear() for i in range(len(wcktkeepers)): item = QtWidgets.QListWidgetItem(wcktkeepers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(69) item.setFont(font) self.availablelist.addItem(item) #Radio Functions end #Other functions: def checkerror(self):# check for errors msg = QMessageBox() if self.wicketerscount > 1: msg.setIcon(QMessageBox.Warning) msg.setInformativeText('Only 1 wicketkeeper is allowed!') msg.setWindowTitle("Error") msg.exec_() return 0 if self.totalcount < 11 : return 0 if self.wicketerscount < 1: return 0 if self.avail_points <= -1: msg.setIcon(QMessageBox.Warning) msg.setInformativeText('Not enough points!') msg.setWindowTitle("Error") msg.exec_() return 0 return 1 def reset(self): # reset local variables, lists self.enablebuttons() self.load_names() self.used_points = 0 self.alrdscount = 0 self.wicketerscount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.totalcount = 0 self.avail_points = 1000 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.bowlcount.setText(str(self.bowlerscount)) self.batcount.setText(str(self.batsmencount)) self.alrcount.setText(str(self.alrdscount)) self.wicketcount.setText(str(self.wicketerscount)) self.selectlist.clear() self.load_names() self.selectedlist.clear()
class Ui_MainWindow(object): def __init__(self): self.newDialog = QtWidgets.QMainWindow() self.new_screen = New() self.new_screen.setupUi(self.newDialog) self.EvaluateWindow = QtWidgets.QMainWindow() self.eval_screen = Eva() self.eval_screen.setupUi(self.EvaluateWindow) self.openDialog = QtWidgets.QMainWindow() self.open_screen = Open() self.open_screen.setupUi(self.openDialog) def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.resize(860, 556) MainWindow.setStyleSheet("\n" "\n" "background-color: rgb(234, 228, 221);") self.central_w = QtWidgets.QWidget(MainWindow) self.central_w.setObjectName("central_w") self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.central_w) self.verticalLayout_3.setObjectName("verticalLayout_3") spacerItem = QtWidgets.QSpacerItem(20, 40, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Preferred) self.verticalLayout_3.addItem(spacerItem) self.frame = QtWidgets.QFrame(self.central_w) self.frame.setStyleSheet("background-color: rgb(241, 235, 255);\n" "font: 75 10pt \"MS Shell Dlg 2\";\n" "") self.frame.setFrameShape(QtWidgets.QFrame.StyledPanel) self.frame.setFrameShadow(QtWidgets.QFrame.Raised) self.frame.setObjectName("frame") self.gridLayout = QtWidgets.QGridLayout(self.frame) self.gridLayout.setContentsMargins(-1, 5, -1, 24) self.gridLayout.setObjectName("gridLayout") self.label_10 = QtWidgets.QLabel(self.frame) self.label_10.setObjectName("label_10") self.gridLayout.addWidget(self.label_10, 1, 4, 1, 1) #bowl self.BOWL = QtWidgets.QLabel(self.frame) self.BOWL.setStyleSheet("color: rgb(0, 170, 255);") self.BOWL.setObjectName("BOWL") self.gridLayout.addWidget(self.BOWL, 1, 3, 1, 1) #all-rouder self.ARL = QtWidgets.QLabel(self.frame) self.ARL.setStyleSheet("color: rgb(0, 170, 255);") self.ARL.setObjectName("ARL") self.gridLayout.addWidget(self.ARL, 1, 5, 1, 1) #bat self.BAT = QtWidgets.QLabel(self.frame) self.BAT.setStyleSheet("color: rgb(0, 170, 255);") self.BAT.setObjectName("BAT") self.gridLayout.addWidget(self.BAT, 1, 1, 1, 1) self.label_2 = QtWidgets.QLabel(self.frame) font = QtGui.QFont() font.setFamily("MS Shell Dlg 2") font.setPointSize(10) font.setBold(False) font.setItalic(False) font.setWeight(9) self.label_2.setFont(font) self.label_2.setObjectName("label_2") self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1) #wicket keeper self.WK = QtWidgets.QLabel(self.frame) self.WK.setStyleSheet("color: rgb(0, 170, 255);") self.WK.setObjectName("WK") self.gridLayout.addWidget(self.WK, 1, 7, 1, 1) self.label_12 = QtWidgets.QLabel(self.frame) self.label_12.setObjectName("label_12") self.gridLayout.addWidget(self.label_12, 1, 6, 1, 1) self.label_4 = QtWidgets.QLabel(self.frame) font = QtGui.QFont() font.setFamily("MS Shell Dlg 2") font.setPointSize(10) font.setBold(False) font.setItalic(False) font.setWeight(9) self.label_4.setFont(font) self.label_4.setObjectName("label_4") self.gridLayout.addWidget(self.label_4, 1, 2, 1, 1) self.label = QtWidgets.QLabel(self.frame) font = QtGui.QFont() font.setFamily("Comic Sans MS") font.setPointSize(9) font.setBold(False) font.setItalic(True) font.setWeight(50) self.label.setFont(font) self.label.setStyleSheet("\n" "font: italic 9pt \"Comic Sans MS\";") self.label.setObjectName("label") self.gridLayout.addWidget(self.label, 0, 0, 1, 1) self.verticalLayout_3.addWidget(self.frame) self.frame_2 = QtWidgets.QFrame(self.central_w) self.frame_2.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";\n" "border-color: rgb(255, 255, 255);") self.frame_2.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_2.setFrameShadow(QtWidgets.QFrame.Plain) self.frame_2.setLineWidth(0) self.frame_2.setObjectName("frame_2") self.horizontalLayout = QtWidgets.QHBoxLayout(self.frame_2) self.horizontalLayout.setContentsMargins(46, 8, 23, 5) self.horizontalLayout.setObjectName("horizontalLayout") self.label_6 = QtWidgets.QLabel(self.frame_2) self.label_6.setStyleSheet("font: 75 9pt \"MS Shell Dlg 2\";") self.label_6.setObjectName("label_6") self.horizontalLayout.addWidget(self.label_6) #Points-available self.points_available = QtWidgets.QLabel(self.frame_2) self.points_available.setStyleSheet("color: rgb(85, 170, 255);") self.points_available.setObjectName("points_available") self.horizontalLayout.addWidget(self.points_available) self.label_7 = QtWidgets.QLabel(self.frame_2) self.label_7.setObjectName("label_7") self.horizontalLayout.addWidget(self.label_7, 0, QtCore.Qt.AlignRight) #points-used self.points_used = QtWidgets.QLabel(self.frame_2) self.points_used.setStyleSheet("color: rgb(85, 170, 255);") self.points_used.setObjectName("points_used") self.horizontalLayout.addWidget(self.points_used, 0, QtCore.Qt.AlignHCenter) self.verticalLayout_3.addWidget(self.frame_2) self.horizontalLayout_4 = QtWidgets.QHBoxLayout() self.horizontalLayout_4.setObjectName("horizontalLayout_4") spacerItem1 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem1) self.frame_3 = QtWidgets.QFrame(self.central_w) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.frame_3.sizePolicy().hasHeightForWidth()) self.frame_3.setSizePolicy(sizePolicy) self.frame_3.setStyleSheet("border-color: rgb(15, 15, 15);") self.frame_3.setFrameShape(QtWidgets.QFrame.Panel) self.frame_3.setFrameShadow(QtWidgets.QFrame.Plain) self.frame_3.setLineWidth(2) self.frame_3.setMidLineWidth(1) self.frame_3.setObjectName("frame_3") self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_3) self.verticalLayout.setContentsMargins(19, -1, 19, -1) self.verticalLayout.setObjectName("verticalLayout") self.frame_5 = QtWidgets.QFrame(self.frame_3) self.frame_5.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";") self.frame_5.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_5.setFrameShadow(QtWidgets.QFrame.Sunken) self.frame_5.setObjectName("frame_5") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.frame_5) self.horizontalLayout_2.setObjectName("horizontalLayout_2") self.bat_rb = QtWidgets.QRadioButton(self.frame_5) self.bat_rb.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.bat_rb.sizePolicy().hasHeightForWidth()) #Bat radio button self.bat_rb.setSizePolicy(sizePolicy) self.bat_rb.setObjectName("bat_rb") self.horizontalLayout_2.addWidget(self.bat_rb) self.bow_rb = QtWidgets.QRadioButton(self.frame_5) self.bow_rb.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.bow_rb.sizePolicy().hasHeightForWidth()) self.bow_rb.setSizePolicy(sizePolicy) #Bowl radio button self.bow_rb.setObjectName("bow_rb") self.horizontalLayout_2.addWidget(self.bow_rb) self.ar_rb = QtWidgets.QRadioButton(self.frame_5) self.ar_rb.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.ar_rb.sizePolicy().hasHeightForWidth()) self.ar_rb.setSizePolicy(sizePolicy) #All-rounder radio button self.ar_rb.setObjectName("ar_rb") self.horizontalLayout_2.addWidget(self.ar_rb) self.wk_rb = QtWidgets.QRadioButton(self.frame_5) self.wk_rb.setEnabled(False) sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Fixed) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) sizePolicy.setHeightForWidth(self.wk_rb.sizePolicy().hasHeightForWidth()) self.wk_rb.setSizePolicy(sizePolicy) #Wicket-keeper radio button self.wk_rb.setObjectName("wk_rb") self.horizontalLayout_2.addWidget(self.wk_rb) self.verticalLayout.addWidget(self.frame_5) #Available player list(list-widget1) self.av_player = QtWidgets.QListWidget(self.frame_3) self.av_player.setFrameShape(QtWidgets.QFrame.NoFrame) self.av_player.setObjectName("av_player") self.verticalLayout.addWidget(self.av_player) self.horizontalLayout_4.addWidget(self.frame_3) spacerItem2 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem2) self.label_9 = QtWidgets.QLabel(self.central_w) self.label_9.setStyleSheet("font: 20pt \"MS Shell Dlg 2\";") self.label_9.setLineWidth(-10) self.label_9.setMidLineWidth(-10) self.label_9.setObjectName("label_9") self.horizontalLayout_4.addWidget(self.label_9) spacerItem3 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem3) self.frame_4 = QtWidgets.QFrame(self.central_w) self.frame_4.setStyleSheet("border-color: rgb(120, 120, 120);") self.frame_4.setFrameShape(QtWidgets.QFrame.Panel) self.frame_4.setFrameShadow(QtWidgets.QFrame.Plain) self.frame_4.setLineWidth(2) self.frame_4.setMidLineWidth(1) self.frame_4.setObjectName("frame_4") self.verticalLayout_2 = QtWidgets.QVBoxLayout(self.frame_4) self.verticalLayout_2.setContentsMargins(18, 9, 14, -1) self.verticalLayout_2.setSpacing(6) self.verticalLayout_2.setObjectName("verticalLayout_2") self.frame_6 = QtWidgets.QFrame(self.frame_4) self.frame_6.setStyleSheet("font: 75 10pt \"MS Shell Dlg 2\";") self.frame_6.setFrameShape(QtWidgets.QFrame.NoFrame) self.frame_6.setFrameShadow(QtWidgets.QFrame.Raised) self.frame_6.setObjectName("frame_6") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.frame_6) self.horizontalLayout_3.setObjectName("horizontalLayout_3") self.label_8 = QtWidgets.QLabel(self.frame_6) self.label_8.setObjectName("label_8") self.horizontalLayout_3.addWidget(self.label_8, 0, QtCore.Qt.AlignHCenter) self.team_name = QtWidgets.QLabel(self.frame_6) self.team_name.setStyleSheet("color: rgb(85, 170, 255);") self.team_name.setObjectName("team_name") self.horizontalLayout_3.addWidget(self.team_name) self.verticalLayout_2.addWidget(self.frame_6) #Selected player list(list widget-2) self.sel_player = QtWidgets.QListWidget(self.frame_4) self.sel_player.setFrameShape(QtWidgets.QFrame.NoFrame) self.sel_player.setObjectName("sel_player") self.verticalLayout_2.addWidget(self.sel_player) self.horizontalLayout_4.addWidget(self.frame_4) spacerItem4 = QtWidgets.QSpacerItem(13, 345, QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum) self.horizontalLayout_4.addItem(spacerItem4) self.verticalLayout_3.addLayout(self.horizontalLayout_4) MainWindow.setCentralWidget(self.central_w) #Menubar option self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 860, 26)) self.menubar.setObjectName("menubar") self.menuManage_Teams = QtWidgets.QMenu(self.menubar) self.menuManage_Teams.setCursor(QtGui.QCursor(QtCore.Qt.ArrowCursor)) self.menuManage_Teams.setStyleSheet("selection-background-color: rgb(0, 170, 255);\n" "\n" "") self.menuManage_Teams.setObjectName("menuManage_Teams") MainWindow.setMenuBar(self.menubar) self.statusbar = QtWidgets.QStatusBar(MainWindow) self.statusbar.setObjectName("statusbar") MainWindow.setStatusBar(self.statusbar) #New window self.new_t = QtWidgets.QAction(MainWindow) self.new_t.setShortcut("Ctrl+N") self.new_t.setIconText("NEW Team") self.new_t.setShortcutContext(QtCore.Qt.WindowShortcut) self.new_t.setVisible(True) self.new_t.setShortcutVisibleInContextMenu(True) self.new_t.setObjectName("new_t") self.menuManage_Teams.addAction(self.new_t) self.new_t.triggered.connect(self.file_new) #Open window self.open_t = QtWidgets.QAction(MainWindow) self.open_t.setObjectName("open_t") self.menuManage_Teams.addAction(self.open_t) self.open_t.triggered.connect(self.file_open) #Save window self.save_t = QtWidgets.QAction(MainWindow) self.save_t.setObjectName("save_t") self.menuManage_Teams.addAction(self.save_t) self.save_t.triggered.connect(self.file_save) #Evaluate window self.evaluat_t = QtWidgets.QAction(MainWindow) self.evaluat_t.setObjectName("evaluat_t") self.menuManage_Teams.addAction(self.evaluat_t) self.evaluat_t.triggered.connect(self.file_evaluate) #Exit window self.actionQuit = QtWidgets.QAction(MainWindow) self.actionQuit.setObjectName("actionQuit") self.menuManage_Teams.addAction(self.actionQuit) self.actionQuit.triggered.connect(self.quit) self.menubar.addAction(self.menuManage_Teams.menuAction()) self.retranslateUi(MainWindow) QtCore.QMetaObject.connectSlotsByName(MainWindow) # Click-double self.av_player.itemDoubleClicked.connect(self.removelist1) self.sel_player.itemDoubleClicked.connect(self.removelist2) # Initializing points self.avail_points = 1000 self.used_points = 0 self.totalcount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.alrdscount = 0 self.wicketerscount = 0 # Stats of player self.stats = {} self.new_screen.savename.clicked.connect(self.namechange) # Initializing list self.a = [] # Bowler names list self.b = [] # Batsman nameslist self.c = [] # Allrounder names list self.d = [] #Wicketer names list self.list1 = [] # Selectedplayer's list # Radiobuttons clicked self.bat_rb.clicked.connect(self.load_names) self.wk_rb.clicked.connect(self.load_names) self.bow_rb.clicked.connect(self.load_names) self.ar_rb.clicked.connect(self.load_names) def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "MainWindow")) self.label_10.setText(_translate("MainWindow", "AllRounders (AR) ")) self.BOWL.setText(_translate("MainWindow", "##")) self.ARL.setText(_translate("MainWindow", "##")) self.BAT.setText(_translate("MainWindow", "##")) self.label_2.setText(_translate("MainWindow", "Batsman (BAT)")) self.WK.setText(_translate("MainWindow", "##")) self.label_12.setText(_translate("MainWindow", "Wicket-Keeper (WK)")) self.label_4.setText(_translate("MainWindow", "Bowlers (BOW)")) self.label.setText(_translate("MainWindow", "Your Selection")) self.label_6.setText(_translate("MainWindow", "Points Availables")) self.points_available.setText(_translate("MainWindow", "####")) self.label_7.setText(_translate("MainWindow", "Points Used")) self.points_used.setText(_translate("MainWindow", "####")) self.bat_rb.setText(_translate("MainWindow", "BAT")) self.bow_rb.setText(_translate("MainWindow", "BOW")) self.ar_rb.setText(_translate("MainWindow", "AR")) self.wk_rb.setText(_translate("MainWindow", "WK")) self.label_9.setText(_translate("MainWindow", ">")) self.label_8.setText(_translate("MainWindow", "Team Name :")) self.team_name.setText(_translate("MainWindow", "Displayed Here")) self.menuManage_Teams.setTitle(_translate("MainWindow", "Manage Teams")) self.new_t.setText(_translate("MainWindow", "NEW Team")) self.new_t.setShortcut(_translate("MainWindow", "Ctrl+N")) self.open_t.setText(_translate("MainWindow", "OPEN Team")) self.open_t.setShortcut(_translate("MainWindow", "Ctrl+O")) self.save_t.setText(_translate("MainWindow", "SAVE team")) self.save_t.setShortcut(_translate("MainWindow", "Ctrl+S")) self.evaluat_t.setText(_translate("MainWindow", "EVALUATE Team")) self.evaluat_t.setShortcut(_translate("MainWindow", "Ctrl+E")) self.actionQuit.setText(_translate("MainWindow", "QUIT")) # File Open menu def file_open(self): self.openDialog.show() # Evaluate team menu def file_evaluate(self): self.eval_screen.setupUi(self.EvaluateWindow) self.EvaluateWindow.show() # Function for new file menu def file_new(self): self.newDialog.show() def namechange(self): teamname = self.new_screen.team_name.text() cur.execute("SELECT DISTINCT Name FROM teams") data = cur.fetchall() #fetching records for i in data: if i[0] == teamname: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Information) msg.setText("Team with same name already exists!!\nPlease choose another name") msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 if len(teamname) == 0: msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("You cannot leave the field blank!!!") msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 elif teamname.isnumeric(): msg = QtWidgets.QMessageBox() msg.setIcon(QtWidgets.QMessageBox.Warning) msg.setText("Please enter a valid teamname\n(Name must contain atleast one character)!!") msg.setWindowTitle("Invalid Team Name") msg.exec_() return 0 else: self.reset() self.tname = self.new_screen.team_name.text() self.team_name.setText(str(' '+self.tname)) self.newDialog.close() #Function for reset def reset(self): self.enablebuttons() self.load_names() self.used_points = 0 self.alrdscount = 0 self.wicketerscount = 0 self.batsmencount = 0 self.bowlerscount = 0 self.totalcount = 0 self.avail_points = 1000 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) self.list1.clear() self.load_names() self.sel_player.clear() #Function for save team def file_save(self): if not self.error(): #check for error msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' Inufficient Players OR Points !!') msg.setWindowTitle("Fantasy Cricket") msg.exec_() elif self.error(): #To catch exceptions try: cur.execute("SELECT DISTINCT Name FROM teams;") data = cur.fetchall() for i in data: if self.team_name.text() == i[0]: # Check if team already exists print('Updating already there') cur.execute("DELETE FROM teams WHERE Name='" + self.team_name.text() + "';") #Delete the updated team #To handle exception except: print('error') for i in range(self.sel_player.count()): #To catch exception try: cur.execute("INSERT INTO teams (Name,Players,Value) VALUES (?,?,?)", (self.team_name.text(), self.list1[i], player_point[self.list1[i]])) #To handle exceptions except: print('error in operation!') db.commit() #Commit function else: print('---error in operation') # Exit() function def quit(self): msg = QMessageBox() msg.setIcon(QMessageBox.Critical) msg.setInformativeText(' Bye ') msg.setWindowTitle("Fantasy Cricket") msg.exec_() sys.exit() #Radio-buttons functions def load_names(self): Batsman = 'BAT' WicketKeeper = 'WK' Allrounder = 'AR' Bowler = 'BWL' sql1 = "SELECT Player,Value from stats WHERE ctg = '" + Batsman + "';" sql2 = "SELECT Player,Value from stats WHERE ctg = '" + WicketKeeper + "';" sql3 = "SELECT Player,Value from stats WHERE ctg ='" + Allrounder + "';" sql4 = "SELECT Player,Value from stats WHERE ctg = '" + Bowler + "';" #for batsmen cur.execute(sql1) x = cur.fetchall() batsmen = [] for k in x: batsmen.append(k[0]) self.b.append(k[0]) self.stats[k[0]] = k[1] #for bowlers cur.execute(sql2) w = cur.fetchall() bowlers = [] for k in y: bowlers.append(k[0]) self.stats[k[0]] = k[1] self.a.append(k[0]) #for all rounder cur.execute(sql3) z =cur.fetchall() allrounders = [] for k in z: allrounders.append(k[0]) self.stats[k[0]] = k[1] self.c.append(k[0]) #for wicket keepers cur.execute(sql4) y = cur.fetchall() wcktkeepers = [] for k in w: wcktkeepers.append(k[0]) self.stats[k[0]] = k[1] self.d.append(k[0]) for i in self.list1: if i in allrounders: allrounders.remove(i) elif i in batsmen: batsmen.remove(i) elif i in bowlers: bowlers.remove(i) elif i in wcktkeepers: wcktkeepers.remove(i) if self.bat_rb.isChecked() == True: self.av_player.clear() for i in range(len(batsmen)): item = QtWidgets.QListWidgetItem(batsmen[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.bow_rb.isChecked() == True: self.av_player.clear() for i in range(len(bowlers)): item = QtWidgets.QListWidgetItem(bowlers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.ar_rb.isChecked() == True: self.av_player.clear() for i in range(len(allrounders)): item = QtWidgets.QListWidgetItem(allrounders[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) elif self.wk_rb.isChecked() == True: self.av_player.clear() for i in range(len(wcktkeepers)): item = QtWidgets.QListWidgetItem(wcktkeepers[i]) font = QtGui.QFont() font.setBold(True) font.setWeight(75) item.setFont(font) self.av_player.addItem(item) def removelist1(self, item): # Removing from available list to select list self.conditions_1(item.text()) self.av_player.takeItem(self.av_player.row(item)) self.sel_player.addItem(item.text()) self.totalcount = self.sel_player.count() self.list1.append(item.text()) self.error() def conditions_1(self, cat): # Evaluate respective points calculate points self.avail_points -= self.stats[cat] self.used_points += self.stats[cat] if cat in self.a: self.bowlerscount += 1 elif cat in self.d: self.wicketerscount += 1 elif cat in self.c: self.alrdscount += 1 elif cat in self.b: self.batsmencount += 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) def conditions_2(self, cat): # Evaluate respective points calculate points self.avail_points += self.stats[cat] self.used_points -= self.stats[cat] if cat in self.a: self.bowlerscount -= 1 elif cat in self.d: self.wicketerscount -= 1 elif cat in self.c: self.alrdscount -= 1 elif cat in self.b: self.batsmencount -= 1 self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.BOWL.setText(str(self.bowlerscount)) self.BAT.setText(str(self.batsmencount)) self.ARL.setText(str(self.alrdscount)) self.WK.setText(str(self.wicketerscount)) def removelist2(self, item): # Remove from available list to select list self.sel_player.takeItem(self.sel_player.row(item)) self.av_player.addItem(item.text()) self.list1.remove(item.text()) self.totalcount = self.sel_player.count() self.conditions_2(item.text()) def openteam(self): #Open team self.reset() teamname = self.open_screen.open_cb.currentText() self.team_name.setText(teamname) self.enablebuttons() cur.execute("SELECT Players from teams WHERE Name= '" + teamname + "';") x=cur.fetchall() score=[] for i in x: cur.execute("SELECT Value from stats WHERE Player='"+i[0]+"';") y=cur.fetchone() score.append(y[0]) sum=0 for i in score: sum+=i self.sel_player.clear() self.load_names() for i in x: self.sel_player.addItem(i[0]) self.list1.append(i[0]) self.conditions_1(i[0]) self.used_points = sum self.avail_points = 1000 - sum self.points_available.setText(str(self.avail_points)) self.points_used.setText(str(self.used_points)) self.openDialog.close() def enablebuttons(self): self.bat_rb.setEnabled(True) self.bow_rb.setEnabled(True) self.ar_rb.setEnabled(True) self.wk_rb.setEnabled(True) def disablebuttons(self): self.bat_rb.setEnabled(False) self.bow_rb.setEnabled(False) self.ar_rb.setEnabled(False) self.wk_rb.setEnabled(False) def error(self): msg = QMessageBox() if self.wicketerscount > 1: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('Only 1 wicketkeeper is allowed!') msg.setWindowTitle("Error") msg.exec_() return 0 elif self.totalcount > 11: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('No more than 11 players allowed!') msg.setWindowTitle("Selection Error") msg.exec_() return 0 elif self.totalcount < 11 : return 0 elif self.wicketerscount < 1: return 0 elif self.avail_points <= -1: msg.setIcon(QMessageBox.Critical) msg.setInformativeText('Not enough points!') msg.setWindowTitle("Selection Cricket") msg.exec_() return 0 return 1