# -*- coding: utf-8 -*-

# Form implementation generated from reading ui file 'main.ui'
#
# Created by: PyQt5 UI code generator 5.15.2
#
# WARNING: Any manual changes made to this file will be lost when pyuic5 is
# run again.  Do not edit this file unless you know what you are doing.


from PyQt5 import QtCore, QtGui, QtWidgets
import sqlite3
import EvaluateWindow


class Ui_MainWindow(object):
    def setupUi(self, MainWindow):
        MainWindow.setObjectName("MainWindow")
        MainWindow.setWindowTitle("Fantasy Cricket")
        MainWindow.resize(910, 598)
        MainWindow.setMaximumSize(QtCore.QSize(16777215, 16777215))
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        MainWindow.setFont(font)
        MainWindow.setStyleSheet('''QWidget {
background-color: white;
}

QMenu:Selected {
    background-color: rgb(52,73,94);
    border-top: none;
    border-left:none;
    border-bottom:none;
    border-left:3px solid  rgb(44,205,112);
    }
QInputDialog {
    background-color: white;
} 
QInputDialog:QlineEdit {
    border:2px solid red;
}

QPushButton {
	Color: rgb(22, 108, 108);
	padding: 5px;
	Border:2px solid rgb(41, 196, 198);
	border-radius:10px;
    width: 40%;
}

QPushButton:hover {
	background-color: rgb(46, 223, 223);
	color: rgb(255, 255, 255);
}
''')
        self.centralwidget = QtWidgets.QWidget(MainWindow)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.centralwidget.sizePolicy().hasHeightForWidth())
        self.centralwidget.setSizePolicy(sizePolicy)
        self.centralwidget.setObjectName("centralwidget")
        self.gridLayout = QtWidgets.QGridLayout(self.centralwidget)
        self.gridLayout.setObjectName("gridLayout")
        self.horizontalGroupBox = QtWidgets.QGroupBox(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.horizontalGroupBox.sizePolicy().hasHeightForWidth())
        self.horizontalGroupBox.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(9)
        self.horizontalGroupBox.setFont(font)
        self.horizontalGroupBox.setStyleSheet("")
        self.horizontalGroupBox.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignVCenter)
        self.horizontalGroupBox.setObjectName("horizontalGroupBox")
        self.horizontalLayout = QtWidgets.QHBoxLayout(self.horizontalGroupBox)
        self.horizontalLayout.setObjectName("horizontalLayout")
        spacerItem = QtWidgets.QSpacerItem(15, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem)
        self.lbl_bat = QtWidgets.QLabel(self.horizontalGroupBox)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_bat.sizePolicy().hasHeightForWidth())
        self.lbl_bat.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_bat.setFont(font)
        self.lbl_bat.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
        self.lbl_bat.setObjectName("lbl_bat")
        self.horizontalLayout.addWidget(self.lbl_bat)
        self.ln_bat = QtWidgets.QLineEdit(self.horizontalGroupBox)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.ln_bat.setFont(font)
        self.ln_bat.setStyleSheet("QLineEdit {\n"
"    background-color: rgba(255, 255, 255, 0);\n"
"    color: rgb(41, 196, 198);\n"
"    border-style: none;\n"
"}")
        self.ln_bat.setReadOnly(True)
        self.ln_bat.setObjectName("ln_bat")
        self.horizontalLayout.addWidget(self.ln_bat)
        self.lbl_bwl = QtWidgets.QLabel(self.horizontalGroupBox)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_bwl.sizePolicy().hasHeightForWidth())
        self.lbl_bwl.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_bwl.setFont(font)
        self.lbl_bwl.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
        self.lbl_bwl.setObjectName("lbl_bwl")
        self.horizontalLayout.addWidget(self.lbl_bwl)
        self.ln_bwl = QtWidgets.QLineEdit(self.horizontalGroupBox)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.ln_bwl.setFont(font)
        self.ln_bwl.setStyleSheet("QLineEdit {\n"
"background-color: rgba(255, 255, 255, 0);\n"
"    color: rgb(41, 196, 198);\n"
"    border-style: none;\n"
"}")
        self.ln_bwl.setReadOnly(True)
        self.ln_bwl.setObjectName("ln_bwl")
        self.horizontalLayout.addWidget(self.ln_bwl)
        self.lbl_ar = QtWidgets.QLabel(self.horizontalGroupBox)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_ar.sizePolicy().hasHeightForWidth())
        self.lbl_ar.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_ar.setFont(font)
        self.lbl_ar.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
        self.lbl_ar.setObjectName("lbl_ar")
        self.horizontalLayout.addWidget(self.lbl_ar)
        self.ln_ar = QtWidgets.QLineEdit(self.horizontalGroupBox)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.ln_ar.setFont(font)
        self.ln_ar.setStyleSheet("QLineEdit {\n"
"    background-color: rgba(255, 255, 255, 0);\n"
"    color: rgb(41, 196, 198);\n"
"    border-style: none;\n"
"}")
        self.ln_ar.setReadOnly(True)
        self.ln_ar.setObjectName("ln_ar")
        self.horizontalLayout.addWidget(self.ln_ar)
        self.lbl_wk = QtWidgets.QLabel(self.horizontalGroupBox)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_wk.sizePolicy().hasHeightForWidth())
        self.lbl_wk.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_wk.setFont(font)
        self.lbl_wk.setStyleSheet("background-color: rgba(255, 255, 255, 0)")
        self.lbl_wk.setObjectName("lbl_wk")
        self.horizontalLayout.addWidget(self.lbl_wk)
        self.ln_wk = QtWidgets.QLineEdit(self.horizontalGroupBox)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.ln_wk.setFont(font)
        self.ln_wk.setStyleSheet("QLineEdit {\n"
"background-color: rgba(255, 255, 255, 0);\n"
"    color: rgb(41, 196, 198);\n"
"    border-style: none;\n"
"}")
        self.ln_wk.setReadOnly(True)
        self.ln_wk.setObjectName("ln_wk")
        self.horizontalLayout.addWidget(self.ln_wk)
        spacerItem1 = QtWidgets.QSpacerItem(15, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout.addItem(spacerItem1)
        self.gridLayout.addWidget(self.horizontalGroupBox, 1, 0, 1, 1)
        self.horizontalLayout_15 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_15.setObjectName("horizontalLayout_15")
        spacerItem2 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_15.addItem(spacerItem2)
        self.lbl_pts_avl = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_pts_avl.setFont(font)
        self.lbl_pts_avl.setObjectName("lbl_pts_avl")
        self.horizontalLayout_15.addWidget(self.lbl_pts_avl)
        self.ln_pts_avl = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ln_pts_avl.sizePolicy().hasHeightForWidth())
        self.ln_pts_avl.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.ln_pts_avl.setFont(font)
        self.ln_pts_avl.setStyleSheet("QLineEdit {\n"
"    Border-style: none;\n"
"    color:rgb(41, 196, 198);\n"
"}")
        self.ln_pts_avl.setReadOnly(True)
        self.ln_pts_avl.setObjectName("ln_pts_avl")
        self.horizontalLayout_15.addWidget(self.ln_pts_avl)
        spacerItem3 = QtWidgets.QSpacerItem(52, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_15.addItem(spacerItem3)
        self.lbl_pts_used = QtWidgets.QLabel(self.centralwidget)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_pts_used.setFont(font)
        self.lbl_pts_used.setObjectName("lbl_pts_used")
        self.horizontalLayout_15.addWidget(self.lbl_pts_used)
        self.ln_pts_used = QtWidgets.QLineEdit(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ln_pts_used.sizePolicy().hasHeightForWidth())
        self.ln_pts_used.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.ln_pts_used.setFont(font)
        self.ln_pts_used.setStyleSheet("QLineEdit {\n"
"    Border-style: none;\n"
"    color:rgb(41, 196, 198);\n"
"}")
        self.ln_pts_used.setReadOnly(True)
        self.ln_pts_used.setObjectName("ln_pts_used")
        self.horizontalLayout_15.addWidget(self.ln_pts_used)
        self.gridLayout.addLayout(self.horizontalLayout_15, 3, 0, 1, 1)
        self.horizontalWidget_2 = QtWidgets.QWidget(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.horizontalWidget_2.sizePolicy().hasHeightForWidth())
        self.horizontalWidget_2.setSizePolicy(sizePolicy)
        self.horizontalWidget_2.setObjectName("horizontalWidget_2")
        self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.horizontalWidget_2)
        self.horizontalLayout_2.setObjectName("horizontalLayout_2")
        self.frame_left = QtWidgets.QFrame(self.horizontalWidget_2)
        self.frame_left.setStyleSheet("QFrame {\n"
"    border: 1px solid rgba(70, 70, 70, 70);\n"
"    border-radius: 10px;\n"
"}")
        self.frame_left.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_left.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_left.setObjectName("frame_left")
        self.verticalLayout = QtWidgets.QVBoxLayout(self.frame_left)
        self.verticalLayout.setObjectName("verticalLayout")
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        self.rb_bat = QtWidgets.QRadioButton(self.frame_left)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.rb_bat.setFont(font)
        self.rb_bat.setStyleSheet("")
        self.rb_bat.setObjectName("rb_bat")
        self.horizontalLayout_3.addWidget(self.rb_bat)
        self.rb_bow = QtWidgets.QRadioButton(self.frame_left)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.rb_bow.setFont(font)
        self.rb_bow.setObjectName("rb_bow")
        self.horizontalLayout_3.addWidget(self.rb_bow)
        self.rb_ar = QtWidgets.QRadioButton(self.frame_left)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.rb_ar.setFont(font)
        self.rb_ar.setObjectName("rb_ar")
        self.horizontalLayout_3.addWidget(self.rb_ar)
        self.rb_wk = QtWidgets.QRadioButton(self.frame_left)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.rb_wk.setFont(font)
        self.rb_wk.setObjectName("rb_wk")
        self.horizontalLayout_3.addWidget(self.rb_wk)
        self.verticalLayout.addLayout(self.horizontalLayout_3)
        self.lst_select = QtWidgets.QListWidget(self.frame_left)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lst_select.sizePolicy().hasHeightForWidth())
        self.lst_select.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.lst_select.setFont(font)
        self.lst_select.setStyleSheet("QListWidget {\n"
"    border-style: none;\n"
"}\n"
"")
        self.lst_select.setObjectName("lst_select")
        self.verticalLayout.addWidget(self.lst_select)
        self.horizontalLayout_2.addWidget(self.frame_left)
        spacerItem4 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem4)
        self.lbl_arrow = QtWidgets.QLabel(self.horizontalWidget_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_arrow.sizePolicy().hasHeightForWidth())
        self.lbl_arrow.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setPointSize(9)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_arrow.setFont(font)
        self.lbl_arrow.setStyleSheet("color: rgb(41, 196, 198)")
        self.lbl_arrow.setAlignment(QtCore.Qt.AlignCenter)
        self.lbl_arrow.setObjectName("lbl_arrow")
        self.horizontalLayout_2.addWidget(self.lbl_arrow)
        spacerItem5 = QtWidgets.QSpacerItem(20, 20, QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_2.addItem(spacerItem5)
        self.frame_right = QtWidgets.QFrame(self.horizontalWidget_2)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.frame_right.sizePolicy().hasHeightForWidth())
        self.frame_right.setSizePolicy(sizePolicy)
        self.frame_right.setStyleSheet("QFrame {\n"
"    border: 1px solid rgba(70, 70, 70, 70);\n"
"    border-radius: 10px;\n"
"}")
        self.frame_right.setFrameShape(QtWidgets.QFrame.StyledPanel)
        self.frame_right.setFrameShadow(QtWidgets.QFrame.Raised)
        self.frame_right.setObjectName("frame_right")
        self.verticalLayout_3 = QtWidgets.QVBoxLayout(self.frame_right)
        self.verticalLayout_3.setObjectName("verticalLayout_3")
        self.horizontalLayout_14 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_14.setSizeConstraint(QtWidgets.QLayout.SetDefaultConstraint)
        self.horizontalLayout_14.setContentsMargins(-1, 4, -1, 5)
        self.horizontalLayout_14.setSpacing(0)
        self.horizontalLayout_14.setObjectName("horizontalLayout_14")
        self.lbl_team_name = QtWidgets.QLabel(self.frame_right)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Ignored)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_team_name.sizePolicy().hasHeightForWidth())
        self.lbl_team_name.setSizePolicy(sizePolicy)
        self.lbl_team_name.setSizeIncrement(QtCore.QSize(0, 0))
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.lbl_team_name.setFont(font)
        self.lbl_team_name.setStyleSheet("QLabel {\n"
"    border-style: none;\n"
"}")
        self.lbl_team_name.setObjectName("lbl_team_name")
        self.horizontalLayout_14.addWidget(self.lbl_team_name)
        self.ln_team_name = QtWidgets.QLineEdit(self.frame_right)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Minimum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.ln_team_name.sizePolicy().hasHeightForWidth())
        self.ln_team_name.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.ln_team_name.setFont(font)
        self.ln_team_name.setStyleSheet("QLineEdit {\n"
"    Border-style: none;\n"
"    color:rgb(41, 196, 198);\n"
"}")
        self.ln_team_name.setReadOnly(True)
        self.ln_team_name.setObjectName("ln_team_name")
        self.horizontalLayout_14.addWidget(self.ln_team_name)
        self.verticalLayout_3.addLayout(self.horizontalLayout_14)
        self.lst_selected = QtWidgets.QListWidget(self.frame_right)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lst_selected.sizePolicy().hasHeightForWidth())
        self.lst_selected.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(False)
        font.setItalic(False)
        font.setWeight(50)
        self.lst_selected.setFont(font)
        self.lst_selected.setStyleSheet("QListWidget {\n"
"    border-style: none;\n"
"\n"
"}")
        self.lst_selected.setObjectName("lst_selected")
        self.verticalLayout_3.addWidget(self.lst_selected)
        self.horizontalLayout_2.addWidget(self.frame_right)
        self.gridLayout.addWidget(self.horizontalWidget_2, 4, 0, 1, 1)
        self.horizontalLayout_16 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_16.setObjectName("horizontalLayout_16")
        self.btn_exit = QtWidgets.QPushButton(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Fixed, QtWidgets.QSizePolicy.Fixed)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.btn_exit.sizePolicy().hasHeightForWidth())
        self.btn_exit.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.btn_exit.setFont(font)
        self.btn_exit.setStyleSheet("QPushButton{\n"
"    Color: rgb(22, 108, 108);\n"
"    padding: 7px;\n"
"    Border:2px solid rgb(41, 196, 198);\n"
"    border-radius:10px;\n"
"    width: 40%;\n"
"}\n"
"\n"
"QPushButton:hover {\n"
"    background-color: rgb(46, 223, 223);\n"
"    color: rgb(255, 255, 255);\n"
"}\n"
"")
        self.btn_exit.setObjectName("btn_exit")
        self.horizontalLayout_16.addWidget(self.btn_exit)
        self.gridLayout.addLayout(self.horizontalLayout_16, 6, 0, 1, 1)
        self.lbl_heading = QtWidgets.QLabel(self.centralwidget)
        sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Maximum)
        sizePolicy.setHorizontalStretch(0)
        sizePolicy.setVerticalStretch(0)
        sizePolicy.setHeightForWidth(self.lbl_heading.sizePolicy().hasHeightForWidth())
        self.lbl_heading.setSizePolicy(sizePolicy)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(25)
        self.lbl_heading.setFont(font)
        self.lbl_heading.setStyleSheet("QLabel {\n"
"    color: rgb(41, 196, 198);\n"
"}")
        self.lbl_heading.setAlignment(QtCore.Qt.AlignCenter)
        self.lbl_heading.setObjectName("lbl_heading")
        self.gridLayout.addWidget(self.lbl_heading, 0, 0, 1, 1)
        MainWindow.setCentralWidget(self.centralwidget)
        self.menubar = QtWidgets.QMenuBar(MainWindow)
        self.menubar.setGeometry(QtCore.QRect(0, 0, 910, 21))
        self.menubar.setObjectName("menubar")
        self.menuFile = QtWidgets.QMenu(self.menubar)
        self.menuFile.setObjectName("menuFile")
        MainWindow.setMenuBar(self.menubar)
        self.statusbar = QtWidgets.QStatusBar(MainWindow)
        self.statusbar.setObjectName("statusbar")
        MainWindow.setStatusBar(self.statusbar)
        self.actionManage_Teams = QtWidgets.QAction(MainWindow)
        self.actionManage_Teams.setObjectName("actionManage_Teams")
        self.actionNEW_Team = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        self.actionNEW_Team.setFont(font)
        self.actionNEW_Team.setObjectName("actionNEW_Team")
        self.actionOPEN_Team = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        self.actionOPEN_Team.setFont(font)
        self.actionOPEN_Team.setObjectName("actionOPEN_Team")
        self.actionSAVE_Team = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        self.actionSAVE_Team.setFont(font)
        self.actionSAVE_Team.setObjectName("actionSAVE_Team")
        self.actionEVALUATE_Team = QtWidgets.QAction(MainWindow)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        self.actionEVALUATE_Team.setFont(font)
        self.actionEVALUATE_Team.setObjectName("actionEVALUATE_Team")
        self.menuFile.addAction(self.actionNEW_Team)
        self.menuFile.addAction(self.actionOPEN_Team)
        self.menuFile.addAction(self.actionSAVE_Team)
        self.menuFile.addAction(self.actionEVALUATE_Team)
        self.menubar.addAction(self.menuFile.menuAction())

        # widgets disabled
        self.disable_widgets()

        # radio buttons connected
        self.rb_bat.toggled.connect(self.category)
        self.rb_bow.toggled.connect(self.category)
        self.rb_ar.toggled.connect(self.category)
        self.rb_wk.toggled.connect(self.category)

        # List widgets on double click
        self.lst_select.itemDoubleClicked.connect(self.remove_item_list1)
        self.lst_selected.itemDoubleClicked.connect(self.remove_item_list2)

        # Buttons Connected
        self.btn_exit.clicked.connect(self.exit_app)

        # Menu connected
        self.menuFile.triggered[QtWidgets.QAction].connect(self.manage_menu)

        # Initial values
        self.bat = 0
        self.bwl = 0
        self.ar = 0
        self.wk = 0
        self.avl_points = 1000
        self.used_points = 0

        self.retranslateUi(MainWindow)
        QtCore.QMetaObject.connectSlotsByName(MainWindow)

    def retranslateUi(self, MainWindow):
        _translate = QtCore.QCoreApplication.translate
        MainWindow.setWindowTitle(_translate("MainWindow", "Fantasy Cricket"))
        self.horizontalGroupBox.setTitle(_translate("MainWindow", "Your Selection:"))
        self.lbl_bat.setText(_translate("MainWindow", "Batsmen (BAT)"))
        self.ln_bat.setPlaceholderText(_translate("MainWindow", "##"))
        self.lbl_bwl.setText(_translate("MainWindow", "Bowlers (BOW)"))
        self.ln_bwl.setPlaceholderText(_translate("MainWindow", "##"))
        self.lbl_ar.setText(_translate("MainWindow", "Allrounders (AR)"))
        self.ln_ar.setPlaceholderText(_translate("MainWindow", "##"))
        self.lbl_wk.setText(_translate("MainWindow", "Wicket-Keeper (WK)"))
        self.ln_wk.setPlaceholderText(_translate("MainWindow", "##"))
        self.lbl_pts_avl.setText(_translate("MainWindow", "Points Available:"))
        self.lbl_pts_used.setText(_translate("MainWindow", "Points Used:"))
        self.rb_bat.setText(_translate("MainWindow", "BAT"))
        self.rb_bow.setText(_translate("MainWindow", "BOW"))
        self.rb_ar.setText(_translate("MainWindow", "AR"))
        self.rb_wk.setText(_translate("MainWindow", "WK"))
        self.lbl_arrow.setText(_translate("MainWindow", ">"))
        self.lbl_team_name.setText(_translate("MainWindow", "Team Name:"))
        self.btn_exit.setText(_translate("MainWindow", "Exit"))
        self.lbl_heading.setText(_translate("MainWindow", "<strong>BUILD</strong> YOUR OWN DREAM TEAM"))
        self.menuFile.setTitle(_translate("MainWindow", "Manage Teams"))
        self.actionManage_Teams.setText(_translate("MainWindow", "Manage Teams"))
        self.actionNEW_Team.setText(_translate("MainWindow", "NEW Team"))
        self.actionNEW_Team.setShortcut(_translate("MainWindow", "Ctrl+N"))
        self.actionOPEN_Team.setText(_translate("MainWindow", "OPEN Team"))
        self.actionOPEN_Team.setShortcut(_translate("MainWindow", "Ctrl+O"))
        self.actionSAVE_Team.setText(_translate("MainWindow", "SAVE Team"))
        self.actionSAVE_Team.setShortcut(_translate("MainWindow", "Ctrl+S"))
        self.actionEVALUATE_Team.setText(_translate("MainWindow", "EVALUATE Team"))
        self.actionEVALUATE_Team.setShortcut(_translate("MainWindow", "Ctrl+E"))

    # Event Handler for Menu
    def manage_menu(self, action):
        action = (action.text())

        if action.lower() == "new team":
            self.new_team()

        if action.lower() == "save team":
            self.save_team()

        if action.lower() == "open team":
            self.open_team()

        if action.lower() == "evaluate team":
            # Launch the EvaluateWindow
            self.window = QtWidgets.QMainWindow()
            self.user_iterface = EvaluateWindow.Ui_EvaluateWindow()
            self.user_iterface.setupUi(self.window)
            self.window.show()

    # Event handler for NEW Team action
    def new_team(self):
        # Clearing the lists and setting label values to 0
        self.initial_vals()
        self.lst_select.clear()
        self.lst_selected.clear()

        # Setting the team name to none
        name = ""
        self.ln_team_name.setText(name)
        self.disable_widgets()

        # Getting existing teams
        teams = []
        command = f'SELECT name from teams'
        team_list = self.sql_cmd(command, "get")
        for team in team_list:
            teams.append(team[0])

        # Getting the new team name from the user
        condition = True
        while condition:
            input_dialog = QtWidgets.QInputDialog()
            input_dialog.setInputMode(QtWidgets.QInputDialog.TextInput)
            txt, ok = input_dialog.getText(MainWindow, "NEW Team", "Enter your team name:")
            if ok and txt:
                if txt not in teams:
                    self.ln_team_name.setText(str(txt))
                    self.enable_widgets()
                    self.values()
                    condition = False
                else:
                    self.pop_up("Team already exists. Please choose another name")
                    condition = True

    # Event handler for SAVE Team action
    def save_team(self):
        # Error if there is no team
        if self.ln_team_name.text() == "":
            self.pop_up("Hey! Please add a team")
            return

        # Error if the numbers of players is less than 11
        if self.lst_selected.count() < 11:
            self.pop_up("Hey! You need a team of 11 players")
            return

        # Confirmation for Saving
        confirm = self.pop_up("You cannot modify the team once saved!\nAre you sure you want to save?")
        if confirm:
            names = ""
            for x in range(10):
                names += self.lst_selected.item(x).text() + ","
            names += self.lst_selected.item(10).text()

            # Saving in Database (values being the points used to make the team)
            new_row = f'"{self.ln_team_name.text()}", "{names}", 0 ,{self.used_points}'
            command = f'INSERT INTO teams (name, players, value, points_used) values ({new_row});'
            self.sql_cmd(command, "save")

    # Event handler for OPEN Team action
    def open_team(self):
        # Disabling the widgets and setting default values
        self.ln_team_name.setText("")
        self.initial_vals()
        self.lst_select.clear()
        self.disable_widgets()
        self.lst_selected.clear()

        # Getting the name of the teams from the DB
        command = f'SELECT name FROM teams;'
        rows = self.sql_cmd(command, "get")
        teams = []
        for team in rows:
            teams.append(team[0])

        # Giving the user an option to select name of team
        team_name, ok = QtWidgets.QInputDialog.getItem(MainWindow, "Fantasy Cricket", "Choose a Team", teams, 0, False)
        if ok and team_name:
            self.ln_team_name.setText(team_name)
        else:
            return

        # Getting the name of the players from the DB
        command = f'SELECT * FROM teams WHERE name = "{team_name}";'
        rows = self.sql_cmd(command, "get")
        players = rows[0][1].split(",")
        self.lst_selected.addItems(players)

        # Setting the available and used points
        self.used_points = rows[0][3]
        self.avl_points = 1000 - self.used_points

        # Incrementing the number of category selected
        for x in range(11):
            player = self.lst_selected.item(x).text()
            command = f'SELECT ctg FROM stats WHERE player = "{player}";'
            rows = self.sql_cmd(command, "get")
            category = rows[0][0]
            if category == "BAT":
                self.bat += 1
            if category == "BWL":
                self.bwl += 1
            if category == "AR":
                self.ar += 1
            if category == "WK":
                self.wk += 1

        # showing the values
        self.values()

    # Show values in the game
    def values(self):
        self.ln_bat.setText(str(self.bat))
        self.ln_bwl.setText(str(self.bwl))
        self.ln_ar.setText(str(self.ar))
        self.ln_wk.setText(str(self.wk))
        self.ln_pts_avl.setText(str(self.avl_points))
        self.ln_pts_used.setText(str(self.used_points))

    # Setting the initial values of the required variables
    def initial_vals(self):
        self.bat = 0
        self.bwl = 0
        self.ar = 0
        self.wk = 0
        self.avl_points = 1000
        self.used_points = 0

    # Fill the list widget with names
    def list_fill(self, category):
        # Clearing the list
        self.lst_select.clear()

        # Getting the player names
        command = f'SELECT * FROM stats WHERE ctg = "{category}";'
        rows = self.sql_cmd(command, "get")
        player_names = []
        selected_players = []
        for names in rows:
            player_names.append(names[0])
        for x in range(self.lst_selected.count()):
            selected_players.append(self.lst_selected.item(x).text())

        # adding the names in the list
        for name in player_names:
            if name not in selected_players:
                self.lst_select.addItem(name)

    # Rules of the game
    def rules(self, ctg, name):
        command = f'SELECT * FROM stats WHERE player = "{name}";'
        row = self.sql_cmd(command, "get")
        error_msg = ""

        # Checking if the user has enough points
        if row[0][5] + self.used_points > 1000:
            error_msg += "You don't have the points to select this player. "
        if self.avl_points - row[0][5] <= 0:
            error_msg += "Points Exhausted. "

        # restricting the user to take only required players
        if ctg == "BAT" and (self.bat + 1) > 5:
            error_msg += "You can only add 5 Batsmen. "
        if ctg == "BWL" and (self.bwl + 1) > 3:
            error_msg += "You can only add 3 Bowlers. "
        if ctg == "AR" and (self.ar + 1) > 2:
            error_msg += "You can only add 2 All Rounders. "
        if ctg == "WK" and (self.wk + 1) > 1:
            error_msg += "You can only add 1 Wicket keeper. "

        if error_msg != "":
            self.pop_up(error_msg)
            return False
        else:
            if ctg == "BAT":
                self.bat += 1
            if ctg == "BWL":
                self.bwl += 1
            if ctg == "AR":
                self.ar += 1
            if ctg == "WK":
                self.wk += 1
            self.avl_points -= row[0][5]
            self.used_points += row[0][5]

        self.values()
        return True

    # Removing items from lst_select and adding it to lst_selected
    def remove_item_list1(self, item):
        category = ""
        if self.rb_bat.isChecked():
            category = "BAT"
        if self.rb_bow.isChecked():
            category = "BWL"
        if self.rb_ar.isChecked():
            category = "AR"
        if self.rb_wk.isChecked():
            category = "WK"

        # Attaching the rules and removing items from lst_select
        rule = self.rules(category, item.text())
        if rule is True:
            self.lst_select.takeItem(self.lst_select.row(item))
            self.lst_selected.addItem(item.text())

    # Removing items from lst_selected and adding it to lst_select
    def remove_item_list2(self, item):
        self.lst_selected.takeItem(self.lst_selected.row(item))
        command = f'SELECT * FROM stats WHERE player = "{item.text()}";'
        rows = self.sql_cmd(command, "get")

        ctg = rows[0][6]
        self.avl_points += rows[0][5]
        self.used_points -= rows[0][5]

        if ctg == "BAT":
            self.bat -= 1
            if self.rb_bat.isChecked():
                self.lst_select.addItem(item.text())
        if ctg == "BWL":
            self.bwl -= 1
            if self.rb_bow.isChecked():
                self.lst_select.addItem(item.text())
        if ctg == "AR":
            self.ar -= 1
            if self.rb_ar.isChecked():
                self.lst_select.addItem(item.text())
        if ctg == "WK":
            self.wk -= 1
            if self.rb_wk.isChecked():
                self.lst_select.addItem(item.text())

        self.values()

    # Getting the category and connecting to self.list_fill
    def category(self):
        category = ""
        if self.rb_bat.isChecked():
            category = "BAT"
        if self.rb_bow.isChecked():
            category = "BWL"
        if self.rb_ar.isChecked():
            category = "AR"
        if self.rb_wk.isChecked():
            category = "WK"

        self.list_fill(category)

    # Disabling all widgets
    def disable_widgets(self):
        self.rb_bat.setEnabled(False)
        self.rb_bow.setEnabled(False)
        self.rb_ar.setEnabled(False)
        self.rb_wk.setEnabled(False)
        self.lst_select.setEnabled(False)
        self.lst_selected.setEnabled(False)

    # Enabling all widgets
    def enable_widgets(self):
        self.rb_bat.setEnabled(True)
        self.rb_bow.setEnabled(True)
        self.rb_ar.setEnabled(True)
        self.rb_wk.setEnabled(True)
        self.lst_select.setEnabled(True)
        self.lst_selected.setEnabled(True)

    # Popups for errors
    def pop_up(self, text):
        window = QtWidgets.QMessageBox()
        window.setWindowTitle("Fantasy Cricket")
        window.setStyleSheet('''QMessageBox {
    background-color: white;
    font-family: segoe ui;
    }
    QPushButton {
	Color: rgb(22, 108, 108);
	padding: 7px;
	Border:2px solid rgb(41, 196, 198);
	border-radius:10px;
    width: 40%;
}

QPushButton:hover {
	background-color: rgb(46, 223, 223);
	color: rgb(255, 255, 255);
}
''')

        window.setText(text)
        font = QtGui.QFont()
        font.setFamily("Segoe UI")
        font.setPointSize(10)
        window.setFont(font)
        window.setStandardButtons(QtWidgets.QMessageBox.Ok | QtWidgets.QMessageBox.Cancel)

        ok = window.exec()
        if ok == QtWidgets.QMessageBox.Ok:
            return True
        else:
            return False

    # Sql commands
    def sql_cmd(self, command, type):
        try:
            connect_db = sqlite3.connect("fantasy_cricket.db")
            cursor = connect_db.cursor()

            if type.lower() == "get":
                cmd = command
                cursor.execute(cmd)
                rows = cursor.fetchall()
                return rows
            elif type.lower() == "save":
                try:
                    cmd = command
                    cursor.execute(cmd)
                    self.pop_up("Saved successfully")
                    connect_db.commit()

                except:
                    self.pop_up("Error")
                    connect_db.rollback()

        except:
            self.pop_up("Error in connecting the Database.")
            sys.exit()

    # exit from the application
    def exit_app(self):
        ok = self.pop_up("Are you sure you want to exit?")

        if ok:
            sys.exit()
        else:
            return


if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    MainWindow = QtWidgets.QMainWindow()
    ui = Ui_MainWindow()
    ui.setupUi(MainWindow)
    MainWindow.show()
    sys.exit(app.exec_())
