Untitled

mail@pastecode.io avatar
unknown
python
2 years ago
35 kB
3
Indexable
Never
import ctypes
import sys

from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import Qt, QCoreApplication
from PyQt5.QtGui import QFont
from PyQt5.QtWidgets import QApplication, QPushButton, QWidget, QLineEdit, QVBoxLayout, QFormLayout, QLabel, \
    QGridLayout, QDesktopWidget, QFrame, QHBoxLayout, \
    QSizeGrip, QStackedWidget, QRadioButton, QCheckBox, QComboBox
from DBconnect import Connect


class LoggedWin(QWidget):
    # def __init__(self, customerID):
    customerID = 'C001'

    def __init__(self):
        super().__init__()
        customerID = 'C001'
        title = 'Taxi booking system'
        left = 0
        top = 0
        width = 700
        height = 500
        self.setWindowTitle(title)
        self.setGeometry(left, top, width, height)
        qtRectangle = self.frameGeometry()
        centerPoint = QDesktopWidget().availableGeometry().center()
        qtRectangle.moveCenter(centerPoint)
        self.move(qtRectangle.topLeft())
        self.setContentsMargins(0, 0, 0, 0)
        self.setMinimumSize(680, 430)

        myappid = 'mycompany.myproduct.subproduct.version'  # ICON ON BOTTOM BAR WINdows
        ctypes.windll.shell32.SetCurrentProcessExplicitAppUserModelID(myappid)
        self.setWindowIcon(QtGui.QIcon('img\\taxiiii.png'))

        self.selfLayout = QHBoxLayout(self)
        self.set_Margins_And_Spac_0(self.selfLayout)
        # remove title bar
        self.setWindowFlags(QtCore.Qt.FramelessWindowHint)
        # set main background transparent
        self.setAttribute(QtCore.Qt.WA_TranslucentBackground)

        # QSizeGrip(self.statusFrame)

        # ----------------------------------BUTTON FRAME -------------------------------------------------------------
        # CREATING BUTTON FRAME
        self.buttonFrame = QFrame(self)
        self.buttonFrame.setMinimumSize(170, 400)
        self.buttonFrame.setMaximumSize(170, 16777215)
        self.buttonFrame.setStyleSheet("background-color:black")
        self.buttonLayout = QVBoxLayout(self.buttonFrame)
        self.set_Margins_And_Spac_0(self.buttonLayout)

        # CREATING BUTTONS IN BUTTON FRAME------------------
        # Book TRIP BUTTON
        self.bookTripFra = QFrame(self.buttonFrame)  # Adding Frame to Button Frame
        self.bookTripBut = QPushButton("Book a trip")  # creating pushbutton
        self.personalizeButtons(self.bookTripBut)  # calling function that personailize a button
        self.bookTripLayout = QGridLayout(self.bookTripFra)  # creating a layout for one button frame
        self.bookTripLayout.setContentsMargins(0, 0, 0,
                                               0)  # deleting margins in layout so button can expand for whole frame
        self.bookTripLayout.setSpacing(0)
        self.bookTripLayout.addWidget(self.bookTripBut)  # adding buutton to layout so it can be visable

        self.bookTripBut.clicked.connect(lambda: self.book_Trip_Clicked())  # calling function for that button

        # BOOKED TRIPS BUTTON
        self.bookedFra = QFrame(self.buttonFrame)
        self.bookedBut = QPushButton("Booked trip")
        self.personalizeButtons(self.bookedBut)
        self.bookedLayout = QGridLayout(self.bookedFra)
        self.set_Margins_And_Spac_0(self.bookedLayout)
        self.bookedLayout.addWidget(self.bookedBut)

        self.bookedBut.clicked.connect(lambda: self.booked_Trip_Clicked())

        # PERSONAL INFORMATION BUTTON
        self.personalInfFra = QFrame(self.buttonFrame)
        self.personalInfBut = QPushButton("Personal\nInformation")
        self.personalizeButtons(self.personalInfBut)
        self.personalInfLayout = QGridLayout(self.personalInfFra)
        self.set_Margins_And_Spac_0(self.personalInfLayout)
        self.personalInfLayout.addWidget(self.personalInfBut)

        self.personalInfBut.clicked.connect(lambda: self.personal_Inf_Clicked())

        # LOGOUT BUTTON
        self.logoutFra = QFrame(self.buttonFrame)
        self.logoutFra.setMinimumSize(190, 40)
        self.logoutFra.setMaximumSize(190, 40)
        self.logoutBut = QPushButton("Logout")
        self.logoutBut.setFont(QFont('Times', 13))
        self.logoutBut.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                           QtWidgets.QSizePolicy.MinimumExpanding))
        self.logoutBut.setStyleSheet("""
            QPushButton {
                background-color: #202020;
                color:white;
                text-align: left;
            }
            QPushButton:hover {
                background-color: red;
                color: #202020;
            }""")
        self.logoutLayout = QGridLayout(self.logoutFra)
        self.set_Margins_And_Spac_0(self.logoutLayout)
        self.logoutLayout.addWidget(self.logoutBut)

        #########
        self.basicButtons()  # Function that changed color of buttons and adding hover effect
        self.clickedButton(self.bookTripBut)
        # ADDING BUTTONS TO FRAME
        self.buttonLayout.addWidget(self.bookTripFra)
        self.buttonLayout.addWidget(self.bookedFra)
        self.buttonLayout.addWidget(self.personalInfFra)
        self.buttonLayout.addWidget(self.logoutFra)

        ############################################BUTTON FRAME FINISH###########################################

        ###########################################RIGHT HAND FRAME###########################################
        self.rightFrame = QFrame(self)
        self.rightFrame.setStyleSheet("background-color:white")
        self.rightLayout = QVBoxLayout(self.rightFrame)
        self.set_Margins_And_Spac_0(self.rightLayout)

        # ====================================================Creating title frame
        self.titleBarFrame = QFrame(self.rightFrame)
        self.titleBarFrame.setMinimumHeight(30)
        self.titleBarFrame.setMaximumHeight(30)
        self.titleBarLayout = QHBoxLayout(self.titleBarFrame)
        self.set_Margins_And_Spac_0(self.titleBarLayout)

        # name of app label
        self.nameFrame = QFrame(self.titleBarFrame)
        self.nameLbl = QLabel()
        self.nameLbl.setText("Taxi booking system")
        self.nameLbl.setFont(QFont('Times', 13))
        self.nameLbl.setStyleSheet("""
                            QLabel {
                                background-color: #202020;
                                color:white;;
                            }""")
        self.nameLbl.setContentsMargins(0, 0, 0, 0)
        self.nameLbl.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                         QtWidgets.QSizePolicy.MinimumExpanding))
        self.nameLbl.setAlignment(Qt.AlignCenter)
        self.nameLayout = QGridLayout(self.nameFrame)
        self.set_Margins_And_Spac_0(self.nameLayout)

        self.nameLayout.addWidget(self.nameLbl)

        # Minimalize app button----
        self.minimalizeFrame = QFrame(self.titleBarFrame)
        self.minimalizeFrame.setMinimumSize(30, 30)
        self.minimalizeFrame.setMaximumSize(30, 30)
        self.minimalizeBut = QPushButton("_")
        self.minimalizeBut.setFont(QFont('Times', 13))
        self.minimalizeBut.setContentsMargins(0, 0, 0, 0)
        self.minimalizeBut.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                               QtWidgets.QSizePolicy.MinimumExpanding))
        self.minimalizeBut.setStyleSheet("""
                    QPushButton {
                        background-color: #202020;
                        color:white;;
                    }
                    QPushButton:hover {
                        background-color: grey;
                        color: #202020;
                    }""")
        self.minimalizeLayout = QGridLayout(self.minimalizeFrame)
        self.set_Margins_And_Spac_0(self.minimalizeLayout)
        self.minimalizeLayout.addWidget(self.minimalizeBut)
        # action
        self.minimalizeBut.clicked.connect(self.showMinimized)

        # maximalize app button-----
        self.maximalizeFrame = QFrame(self.titleBarFrame)
        self.maximalizeFrame.setMinimumSize(30, 30)
        self.maximalizeFrame.setMaximumSize(30, 30)
        self.maximalizeBut = QPushButton("🡥")
        self.maximalizeBut.setFont(QFont('Times', 13))
        self.maximalizeBut.setContentsMargins(0, 0, 0, 0)
        self.maximalizeBut.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                               QtWidgets.QSizePolicy.MinimumExpanding))
        self.maximalizeBut.setStyleSheet("""
                            QPushButton {
                                background-color: #202020;
                                color:white;;
                            }
                            QPushButton:hover {
                                background-color: grey;
                                color: #202020;
                            }""")
        self.maximalizeLayout = QGridLayout(self.maximalizeFrame)
        self.set_Margins_And_Spac_0(self.maximalizeLayout)
        self.maximalizeLayout.addWidget(self.maximalizeBut)
        # action
        self.maximalizeBut.clicked.connect(self.resMaxWin)

        # close app button----
        self.closeFrame = QFrame(self.titleBarFrame)
        self.closeFrame.setMinimumSize(30, 30)
        self.closeFrame.setMaximumSize(30, 30)
        self.closeBut = QPushButton("X")
        self.closeBut.setFont(QFont('Times', 13))
        self.closeBut.setContentsMargins(0, 0, 0, 0)
        self.closeBut.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                          QtWidgets.QSizePolicy.MinimumExpanding))
        self.closeBut.setStyleSheet("""
                                    QPushButton {
                                        background-color: #202020;
                                        color:white;;
                                    }
                                    QPushButton:hover {
                                        background-color: red;
                                        color: #202020;
                                    }""")
        self.closeLayout = QGridLayout(self.closeFrame)
        self.set_Margins_And_Spac_0(self.closeLayout)
        self.closeLayout.addWidget(self.closeBut)
        # action
        self.closeBut.clicked.connect(QCoreApplication.instance().quit)

        # ADDING content to information frame
        self.titleBarLayout.addWidget(self.nameFrame)
        self.titleBarLayout.addWidget(self.minimalizeFrame)
        self.titleBarLayout.addWidget(self.maximalizeFrame)
        self.titleBarLayout.addWidget(self.closeFrame)

        # ====================================================finish title frame
        # ====================================================Create content frame

        self.contentFrame = QFrame(self.rightFrame)
        self.contentLayout = QVBoxLayout(self.contentFrame)
        self.set_Margins_And_Spac_0(self.contentLayout)
        self.contentStack = QStackedWidget(self.contentFrame)

        self.bookTripStack = QFrame()
        self.bookedStack = QFrame()
        self.personalInfStack = QFrame()

        self.bookTripStackUI()
        self.bookedStackUI()
        self.personalInfStackUI()

        self.contentStack.addWidget(self.bookTripStack)
        self.contentStack.addWidget(self.bookedStack)
        self.contentStack.addWidget(self.personalInfStack)

        self.contentLayout.addWidget(self.contentStack)

        # ====================================================Finish content frame
        # ====================================================Create bottom bar

        self.statusFrame = QFrame(self.rightFrame)
        self.statusFrame.setMinimumHeight(15)
        self.statusFrame.setMaximumHeight(15)
        self.statusFrame.setStyleSheet("background-color:grey")
        self.statusLayout = QHBoxLayout(self.statusFrame)
        self.set_Margins_And_Spac_0(self.statusLayout)

        #  label in status bar------------
        self.bottomFrame = QFrame(self.statusFrame)
        self.bottomLbl = QLabel()

        query = f"SELECT `CFName`, `CSName` FROM `customer` WHERE `CustomerID` = '{customerID}';"
        forenameAndSurname = Connect.select_DB(query)
        self.bottomLbl.setText(f"Hello {forenameAndSurname[0][0].capitalize()} {forenameAndSurname[0][1].capitalize()}")
        self.bottomLbl.setFont(QFont('Times', 12))
        self.bottomLbl.setStyleSheet("""
                                    QLabel {
                                        background-color: grey;
                                        color:white;;
                                    }""")
        self.bottomLbl.setContentsMargins(0, 0, 0, 0)
        self.bottomLbl.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                           QtWidgets.QSizePolicy.MinimumExpanding))
        self.bottomLbl.setAlignment(Qt.AlignCenter)
        self.bottomLayout = QGridLayout(self.bottomFrame)
        self.set_Margins_And_Spac_0(self.bottomLayout)
        self.bottomLayout.addWidget(self.bottomLbl)

        # SIZE GRIP----------------------
        self.sizeFrame = QFrame(self.statusFrame)
        self.sizeFrame.setMinimumSize(5, 5)
        self.sizeFrame.setMaximumSize(5, 5)
        self.sizeFrame.setStyleSheet("background-color:black")
        self.sizeGrip = QSizeGrip(self.sizeFrame)
        self.sizeGrip.setContentsMargins(0, 0, 0, 0)
        self.sizeGrip.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                          QtWidgets.QSizePolicy.MinimumExpanding))
        self.sizeLayout = QHBoxLayout(self.sizeFrame)
        self.set_Margins_And_Spac_0(self.sizeLayout)
        self.sizeLayout.addWidget(self.sizeGrip)

        # Adding content to status bar

        self.statusLayout.addWidget(self.bottomFrame, alignment=QtCore.Qt.AlignLeft)
        self.statusLayout.addWidget(self.sizeFrame, alignment=QtCore.Qt.AlignRight | QtCore.Qt.AlignBottom)

        # ====================================================finish bottom bar

        # Adding content to right frame
        self.rightLayout.addWidget(self.titleBarFrame)
        self.rightLayout.addWidget(self.contentFrame)
        self.rightLayout.addWidget(self.statusFrame)
        #############################################RIGHT HAND FRAME FINISH ###########################################
        # ADDING FRAME WITH BUTTONS AND right hand FRAME TO WINDOW
        self.selfLayout.addWidget(self.buttonFrame)
        self.selfLayout.addWidget(self.rightFrame)

        # MOVE WINDOW -------------------
        def moveWindow(e):
            if self.isMaximized() == False:
                if e.buttons() == Qt.LeftButton:
                    self.move(self.pos() + e.globalPos() - self.clickPosition)
                    self.clickPosition = e.globalPos()
                    e.accept()

        self.titleBarFrame.mouseMoveEvent = moveWindow

    def book_Trip_Clicked(self):
        self.basicButtons()
        self.clickedButton(self.bookTripBut)
        self.display(0)

    def set_Margins_And_Spac_0(self,layout):
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)


    def booked_Trip_Clicked(self):
        self.basicButtons()
        self.clickedButton(self.bookedBut)
        self.display(1)

    def personal_Inf_Clicked(self):
        self.basicButtons()
        self.clickedButton(self.personalInfBut)
        self.display(2)

    def display(self, i):
        self.contentStack.setCurrentIndex(i)

    # -------RESTORE MAXIMALIZE WINDOW FUNCTION
    def resMaxWin(self):
        if self.isMaximized():
            self.showNormal()
            self.maximalizeBut.setText("🡥")
        else:
            self.showMaximized()
            self.maximalizeBut.setText("🡧")

    # ------ MOUSE POSITION
    def mousePressEvent(self, event):
        self.clickPosition = event.globalPos()

    def basicButtons(self):
        self.bookedBut.setStyleSheet("""
                            QPushButton {
                                background-color: #202020;
                                color:white;
                                text-align: left;
                                border: none;
                            }
                            QPushButton:hover {
                                background-color: white;
                                color: #202020;
                                text-align: left;
                                border: none;
                                
                            }
                            QPushButton:pressed {
                                border: none;
                                text-align: left;
                            }""")
        self.bookTripBut.setStyleSheet("""
                            QPushButton {
                                background-color: #202020;
                                color:white;
                                text-align: left;
                                border: none;
                            }
                            QPushButton:hover {
                                background-color: white;
                                text-align: left;
                                color: #202020;
                                border: none;
                            }
                            QPushButton:pressed {
                                text-align: left;
                                border: none;
                            }""")
        self.personalInfBut.setStyleSheet("""
                            QPushButton {
                                background-color: #202020;
                                color:white;
                                text-align: left;
                                border: none;
                            }
                            QPushButton:hover {
                                background-color: white;
                                color: #202020;
                                border: none;
                            }
                            QPushButton:pressed {
                                border: none;
                            }""")

    def clickedButton(self, button):
        button.setStyleSheet("""
                            QPushButton {
                                background-color: white;
                                color:black;
                                text-align: left;
                                border: none;
                            }
                            """)

    def personalizeButtons(self, button):
        button.setFont(QFont('Times', 15))
        button.setContentsMargins(0, 0, 0, 0)
        button.setSizePolicy(QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding,
                                                   QtWidgets.QSizePolicy.MinimumExpanding))

                                             #Book Trip Stack
    def bookTripStackUI(self):
        layout = QHBoxLayout(self.bookTripStack)
        self.set_Margins_And_Spac_0(layout)

        leftFrame = QFrame(self.bookTripStack)
        leftFrame.setMinimumWidth(360)

        leftLayout = QVBoxLayout(leftFrame)
        self.set_Margins_And_Spac_0(leftLayout)

                                                # IN FRAME
                                                                                #now later Frame
        nowLaterFrame = QFrame(leftFrame)
        topLayout = QHBoxLayout(nowLaterFrame)
        nowLaterFrame.setMinimumHeight(50)
        nowLaterFrame.setMaximumHeight(50)
        self.nowRadio = QRadioButton("now")

        self.nowRadio.setFont(QFont("times", 16))
        self.laterRadio = QRadioButton("later")
        self.laterRadio.setFont(QFont("times", 16))
        self.laterRadio.setChecked(True)
        whenLabel = QLabel("When:")
        whenLabel.setFont(QFont("Times", 16))
        topLayout.addWidget(whenLabel)
        topLayout.addWidget(self.nowRadio)
        topLayout.addWidget(self.laterRadio)

                                                                                     #from to Frame
        fromToFrame = QFrame(leftFrame)
        fromToLayout = QGridLayout(fromToFrame)
        self.streetFromLine = QLineEdit()
        self.streetFromLine.setStyleSheet("QLineEdit {border: 3px solid black;}")
        self.postCodeFrom = QLineEdit()
        self.postCodeFrom.setStyleSheet("QLineEdit {border: 3px solid black;}")
        self.streetToLine = QLineEdit()
        self.streetToLine.setStyleSheet("QLineEdit {border: 3px solid black;}")
        self.postCodeFrom.setFixedWidth(70)
        self.postCodeTo = QLineEdit()
        self.postCodeTo.setStyleSheet("QLineEdit {border: 3px solid black;}")
        self.postCodeTo.setFixedWidth(70)
        fromLbl = QLabel("from")
        fromLbl.setFont(QFont("Times", 16))
        fromToLayout.addWidget(fromLbl, 0, 0, 1, 2, QtCore.Qt.AlignCenter)

        fromFrame = QFrame(fromToFrame)
        fromLayout = QHBoxLayout(fromFrame)
        fromLayout.addWidget(QLabel("street &\nhouse number:"))
        fromLayout.addWidget(self.streetFromLine)
        fromLayout.addWidget(QLabel("post code:"))
        fromLayout.addWidget(self.postCodeFrom)

        fromToLayout.addWidget(fromFrame, 1, 0, 1, 3, QtCore.Qt.AlignLeft)

        toLabel = QLabel("to")
        toLabel.setFont(QFont("Times", 16))
        fromToLayout.addWidget(toLabel, 2, 0, 1, 2, QtCore.Qt.AlignCenter)

        toFrame = QFrame(fromToFrame)
        toLayout = QHBoxLayout(toFrame)
        toLayout.addWidget(QLabel("street &\nhouse number:"))
        toLayout.addWidget(self.streetToLine)
        toLayout.addWidget(QLabel("post code:"))
        toLayout.addWidget(self.postCodeTo)

        fromToLayout.addWidget(toFrame, 3, 0, 1, 3, QtCore.Qt.AlignLeft)

                                                                                        #when frame
        whenFrame = QFrame(leftFrame)
        whenLayout = QGridLayout(whenFrame)
        self.dateEdit = QtWidgets.QDateEdit(calendarPopup=True)
        self.dateEdit.setStyleSheet(""" QDateEdit{
                                            border : 3px solid black;
                                            background : white;
                                        }
                                        QDateEdit::up-arrow{
                                            border : 2px solid black;
                                            background-color : lightgreen;
                                        }
                                        QDateEdit::down-arrow{
                                            border : 2px solid black;
                                            background-color : green;
                                        }""")
        self.dateEdit.setDateTime(QtCore.QDateTime.currentDateTime())
        self.hoursComboBox = QComboBox()
        self.hoursComboBox.setStyleSheet("QComboBox {border: 3px solid black;}")
        self.hoursComboBox.setFixedWidth(50)
        hours = []
        self.minutesComboBox = QComboBox()
        self.minutesComboBox.setStyleSheet("QComboBox {border: 3px solid black;}")
        self.minutesComboBox.setFixedWidth(50)
        minutes = []
        for i in range(24):
            hours.append(str(i))
        for i in range(0, 60, 5):
            minutes.append(str(i))
        self.searchButton = QPushButton("Search")
        self.searchButton.setStyleSheet("QPushButton {background: grey;}")
        self.afterSearchLabel = QLabel("")
        self.afterSearchLabel.setStyleSheet("QLabel{ color: red}")
        self.hoursComboBox.addItems(hours)
        self.minutesComboBox.addItems(minutes)
        self.selectTime = QLabel("Select time: ")
        self.selectDate = QLabel("Select Date: ")

        selectTimeFrame = QFrame(whenFrame)
        selectTimeLayout = QHBoxLayout(selectTimeFrame)
        selectTimeLayout.addWidget(self.selectTime, QtCore.Qt.AlignRight)
        selectTimeLayout.addWidget(self.hoursComboBox)
        selectTimeLayout.addWidget(self.minutesComboBox)

        selectDateFrame = QFrame(whenFrame)
        selectDateLayout = QHBoxLayout(selectDateFrame)
        selectDateLayout.addWidget(self.selectDate)
        selectDateLayout.addWidget(self.dateEdit)

        whenLayout.addWidget(selectTimeFrame, 0, 0, 1, 3, QtCore.Qt.AlignLeft)
        whenLayout.addWidget(selectDateFrame, 1, 0, 1, 2, QtCore.Qt.AlignLeft)
        whenLayout.addWidget(self.searchButton, 1, 2, 1, 1, QtCore.Qt.AlignRight)
        whenLayout.addWidget(self.afterSearchLabel, 2, 1, 1, 2, QtCore.Qt.AlignRight)




        leftLayout.addWidget(nowLaterFrame)
        leftLayout.addWidget(fromToFrame)
        leftLayout.addWidget(whenFrame)


        self.nowRadio.clicked.connect(self.now_radio_selected)
        self.laterRadio.clicked.connect(self.later_radio_selected)

        self.searchButton.clicked.connect(lambda: self.on_click_search(self.laterRadio.isChecked()))

        #######################RIGHT BOOK TRIP
        rightFrame = QFrame(self.bookTripStack)
        rightFrame.setMaximumWidth(150)
        rightFrame.setMinimumWidth(150)
        rightLayout = QVBoxLayout(rightFrame)
        self.set_Margins_And_Spac_0(rightLayout)

                                                                #BUTTONS and label
                                                                #choose car
        chooseCarFrame = QFrame(rightFrame)
        chooseCarFrame.setMaximumHeight(40)
        chooseCarFrame.setMinimumHeight(40)
        chooseCarLabel = QLabel("Choose car:")
        chooseCarLabel.setAlignment(Qt.AlignCenter)
        chooseCarLabel.setStyleSheet("""
                                        QLabel {
                                            background: black;
                                            color: white;
                                        }""")
        chooseCarLayout = QGridLayout(chooseCarFrame)
        self.set_Margins_And_Spac_0(chooseCarLayout)
        chooseCarLayout.addWidget(chooseCarLabel)
                                                                #economic
        economicFrame = QFrame(rightFrame)

        self.economicButton = QPushButton("ECONOMIC")
        self.personalizeButtons(self.economicButton)
        self.economicButton.setStyleSheet("QPushButton {background: grey}")
        economicLayout = QGridLayout(economicFrame)
        self.set_Margins_And_Spac_0(economicLayout)
        economicLayout.addWidget(self.economicButton)

                                                                #family

        familyFrame = QFrame(rightFrame)
        self.familyButton = QPushButton("FAMILY \n (7 seats)")
        self.personalizeButtons(self.familyButton)
        self.familyButton.setStyleSheet("QPushButton {background: grey}")
        familyLayout = QGridLayout(familyFrame)
        self.set_Margins_And_Spac_0(familyLayout)
        familyLayout.addWidget(self.familyButton)

                                                               #premium

        premiumFrame = QFrame(rightFrame)
        self.premiumButton = QPushButton("Premium")
        self.personalizeButtons(self.premiumButton)
        self.premiumButton.setStyleSheet("QPushButton {background: grey}")
        premiumLayout = QGridLayout(premiumFrame)
        self.set_Margins_And_Spac_0(premiumLayout)
        premiumLayout.addWidget(self.premiumButton)

        self.car_button_enableFalse()
        #############ADDING TO RIGHT FRAME
        rightLayout.addWidget(chooseCarFrame)
        rightLayout.addWidget(economicFrame)
        rightLayout.addWidget(familyFrame)
        rightLayout.addWidget(premiumFrame)

        layout.addWidget(leftFrame)
        layout.addWidget(rightFrame)
                                            #NOW Radiobutton
    def now_radio_selected(self):
        if self.nowRadio.isChecked():
            self.car_button_enableFalse()
            self.minutesComboBox.hide()
            self.hoursComboBox.hide()
            self.dateEdit.hide()
            self.selectTime.hide()
            self.selectDate.hide()
                                            #LEter radiobutton
    def later_radio_selected(self):
        if self.laterRadio.isChecked():
            self.car_button_enableFalse()
            self.minutesComboBox.show()
            self.hoursComboBox.show()
            self.dateEdit.show()
            self.selectTime.show()
            self.selectDate.show()
                                            #Search button
    def on_click_search(self, check):
        if check:
            self.car_button_enableFalse()
            date = self.dateEdit.date().toPyDate()
            hours = str(self.hoursComboBox.currentText())
            minutes = str(self.minutesComboBox.currentText())
            self.carEconomic = []
            self.carFamily = []
            self.carPremium = []
            query = f"""
                        select carType, carPlate, carMake
                        from car
                        WHERE driverID in (
                            SELECT driverID
                            FROM driver
                            WHERE dStatus = 'active'
                            AND driverId NOT IN (SELECT DISTINCT `driverID`
                                FROM trip
                                WHERE (trip.tpickUpDate = '{date}') 
                                AND (trip.tpickUpHour BETWEEN SubTime ('{hours}:{minutes}:00', '00:29:59')
                                AND AddTime('{hours}:{minutes}:00', '00:30:00'))
                                AND (trip.tBookingStatus = 'approved' OR trip.tBookingStatus = 'active')))"""
        else:

            query =f"""
                        select carType, carPlate, carMake
                        from car
                        WHERE driverID in (
                            SELECT driverID
                            FROM driver
                            WHERE dStatus = 'active'
                            AND driverId NOT IN (SELECT DISTINCT `driverID`
                                FROM trip
                                WHERE (trip.tpickUpDate = current_timestamp) 
                                AND (trip.tpickUpHour BETWEEN SubTime (current_timestamp, '00:29:59')
                                AND AddTime(current_timestamp, '00:30:00'))
                                AND (trip.tBookingStatus = 'approved' OR trip.tBookingStatus = 'active')))"""
        carType = Connect.select_DB(query)
        print (carType)
        for i in carType:
            print(i)
            if 'family' in i:
                self.familyButton.setEnabled(True)
                self.carFamily.append((i[1], i[2]))

            if 'premium' in i:
                self.premiumButton.setEnabled(True)
                self.carPremium.append((i[1], i[2]))
            if 'economic' in i:
                self.economicButton.setEnabled(True)
                print(i[1], i[2])
                self.carEconomic.append("ssss")
                print(self.carEconomic)
        print(self.carPremium)
                                            #economic button
    def on_click_economicButton(self, check):
        if check:
            query = f"""
                        select carPlate, carType
                        from car
                        WHERE carType = 'economic'  
                        AND driverID in (
                            SELECT driverID
                            FROM driver
                            WHERE dStatus = 'active'
                            AND driverId NOT IN (SELECT DISTINCT `driverID`
                                FROM trip
                                WHERE (trip.tpickUpDate = '{self.date}') 
                                AND (trip.tpickUpHour BETWEEN SubTime ('{self.hours}:{self.minutes}:00', '00:29:59')
                                AND AddTime('{self.hours}:{self.minutes}:00', '00:30:00'))
                                AND (trip.tBookingStatus = 'approved' OR trip.tBookingStatus = 'active')))
                    """
        else:
            query =f"""
                        select carPlate, carType
                        from car
                        WHERE carType = 'economic'  
                        AND driverID in (
                            SELECT driverID
                            FROM driver
                            WHERE dStatus = 'active'
                            AND driverId NOT IN (SELECT DISTINCT `driverID`
                                FROM trip
                                WHERE (trip.tpickUpDate = current_timestamp) 
                                AND (trip.tpickUpHour BETWEEN SubTime (current_timestamp, '00:29:59')
                                AND AddTime(current_timestamp, '00:30:00'))
                                AND (trip.tBookingStatus = 'approved' OR trip.tBookingStatus = 'active')))
                    """



    def bookedStackUI(self):
        layout = QFormLayout()
        sex = QHBoxLayout()
        sex.addWidget(QRadioButton("Male"))
        sex.addWidget(QRadioButton("Female"))
        layout.addRow(QLabel("Sex"), sex)
        guzik = QPushButton("Guzik")
        layout.addRow(guzik)
        self.datas = QLineEdit()
        layout.addRow("data", self.datas)

        self.bookedStack.setStyleSheet("background-color:blue")
        self.bookedStack.setLayout(layout)

    def personalInfStackUI(self):
        layout = QHBoxLayout()
        layout.addWidget(QLabel("subjects"))
        layout.addWidget(QCheckBox("Physics"))
        layout.addWidget(QCheckBox("Maths"))
        self.personalInfStack.setStyleSheet("background-color:green")
        self.personalInfStack.setLayout(layout)



    def car_button_enableFalse(self):
        self.familyButton.setEnabled(False)
        self.economicButton.setEnabled(False)
        self.premiumButton.setEnabled(False)


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = LoggedWin()
    ex.show()

    sys.exit(app.exec_())