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

# Form implementation generated from reading ui file 'open.ui'
#
# Created by: PyQt5 UI code generator 5.15.0
#
# 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


class Ui_Dialog(object):
    def setupUi(self, Dialog):
        Dialog.setObjectName("Dialog")
        Dialog.resize(459, 468)
        icon = QtGui.QIcon()
        icon.addPixmap(QtGui.QPixmap("icons/netclipart.com-cricket-bat-clipart-1401330.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
        Dialog.setWindowIcon(icon)
        Dialog.setStyleSheet("background-color: rgb(255, 170, 127);")
        self.verticalLayout = QtWidgets.QVBoxLayout(Dialog)
        self.verticalLayout.setObjectName("verticalLayout")
        self.l1 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(20)
        font.setBold(True)
        font.setUnderline(True)
        font.setWeight(75)
        self.l1.setFont(font)
        self.l1.setStyleSheet("background-color: rgb(255, 170, 127);")
        self.l1.setAlignment(QtCore.Qt.AlignCenter)
        self.l1.setObjectName("l1")
        self.verticalLayout.addWidget(self.l1)
        self.horizontalLayout = QtWidgets.QHBoxLayout()
        self.horizontalLayout.setObjectName("horizontalLayout")
        self.l2 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setPointSize(16)
        font.setBold(True)
        font.setUnderline(True)
        font.setWeight(75)
        self.l2.setFont(font)
        self.l2.setAlignment(QtCore.Qt.AlignCenter)
        self.l2.setObjectName("l2")
        self.horizontalLayout.addWidget(self.l2)
        self.combo1 = QtWidgets.QComboBox(Dialog)
        font = QtGui.QFont()
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.combo1.setFont(font)
        self.combo1.setObjectName("combo1")
        # Add the team's name in the combobox
        import sqlite3
        con=sqlite3.connect('cricket.db')
        sql="select name from teams"
        cur=con.execute(sql)
        for row in cur:
            self.combo1.addItem(str(row[0]))
        con.close()
        self.horizontalLayout.addWidget(self.combo1)
        self.show = QtWidgets.QPushButton(Dialog)
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.show.setFont(font)
        self.show.setStyleSheet("background-color: rgb(0, 0, 127);\n"
"color: rgb(255, 170, 0);")
        self.show.setObjectName("show")
        self.show.clicked.connect(self.openteam) # calling the open module
        self.horizontalLayout.addWidget(self.show)
        self.verticalLayout.addLayout(self.horizontalLayout)
        self.horizontalLayout_5 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_5.setObjectName("horizontalLayout_5")
        self.l3 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setFamily("Arial")
        font.setPointSize(12)
        font.setBold(True)
        font.setUnderline(False)
        font.setWeight(75)
        self.l3.setFont(font)
        self.l3.setAlignment(QtCore.Qt.AlignCenter)
        self.l3.setObjectName("l3")
        self.horizontalLayout_5.addWidget(self.l3)
        self.l4 = QtWidgets.QLabel(Dialog)
        font = QtGui.QFont()
        font.setFamily("Arial Unicode MS")
        font.setPointSize(10)
        font.setBold(True)
        font.setWeight(75)
        self.l4.setFont(font)
        self.l4.setText("")
        self.l4.setObjectName("l4")
        self.horizontalLayout_5.addWidget(self.l4)
        self.verticalLayout.addLayout(self.horizontalLayout_5)
        self.horizontalLayout_3 = QtWidgets.QHBoxLayout()
        self.horizontalLayout_3.setObjectName("horizontalLayout_3")
        spacerItem = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem)
        self.list = QtWidgets.QListWidget(Dialog)
        font = QtGui.QFont()
        font.setPointSize(12)
        font.setBold(True)
        font.setWeight(75)
        self.list.setFont(font)
        self.list.setObjectName("list")
        self.horizontalLayout_3.addWidget(self.list)
        spacerItem1 = QtWidgets.QSpacerItem(40, 20, QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)
        self.horizontalLayout_3.addItem(spacerItem1)
        self.verticalLayout.addLayout(self.horizontalLayout_3)

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

    def retranslateUi(self, Dialog):
        _translate = QtCore.QCoreApplication.translate
        Dialog.setWindowTitle(_translate("Dialog", "team"))
        self.l1.setText(_translate("Dialog", " Fantasy Cricket"))
        self.l2.setText(_translate("Dialog", "Select Your Team"))
        self.show.setText(_translate("Dialog", "SHOW"))
        self.l3.setText(_translate("Dialog", "Players"))
        
    # this module opens the team players list based on selected combobox value
    def openteam(self):
        import sqlite3
        con=sqlite3.connect('cricket.db')
        self.list.clear()
        team=self.combo1.currentText()
        sql1="SELECT players,value from teams where name='"+team+"';"
        cur=con.execute(sql1)
        row=cur.fetchone()
        selected=row[0].split(',')
        self.list.addItems(selected)
        self.l4.setText("total points used : {}".format(str(row[1])))

if __name__ == "__main__":
    import sys
    app = QtWidgets.QApplication(sys.argv)
    Dialog = QtWidgets.QDialog()
    ui = Ui_Dialog()
    ui.setupUi(Dialog)
    Dialog.show()
    sys.exit(app.exec_())
