Untitled

 avatar
unknown
python
2 years ago
5.3 kB
7
Indexable
import sys
from PyQt5.QtWidgets import QMainWindow, QApplication, QPushButton, QWidget, QAction, QLineEdit, QTabWidget, \
    QVBoxLayout, QFormLayout, QLabel, QGridLayout, QComboBox, QDesktopWidget
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import pyqtSlot


class App(QMainWindow):

    def __init__(self):
        super().__init__()
        self.title = 'TAXI'
        self.left = 0
        self.top = 0
        self.width = 300
        self.height = 200
        self.setWindowTitle(self.title)
        self.setGeometry(self.left, self.top, self.width, self.height)
        qtRectangle = self.frameGeometry()
        centerPoint = QDesktopWidget().availableGeometry().center()
        print(qtRectangle)
        print(centerPoint)
        qtRectangle.moveCenter(centerPoint)
        self.move(qtRectangle.topLeft())

        self.table_widget = MyTableWidget(self)
        self.setCentralWidget(self.table_widget)

        self.show()


class MyTableWidget(QWidget):

    def __init__(self, parent):
        super(QWidget, self).__init__(parent)
        self.layout = QGridLayout(self)
        # Initialize tab screen
        self.tabs = QTabWidget()
        self.logTab = QWidget()

        self.regTab = QWidget()
        self.tabs.resize(300, 200)

        # Add tabs
        self.tabs.addTab(self.logTab, "Login")
        self.tabs.addTab(self.regTab, "Registration")

        # CREATE LOGIN TAB--------------------------------------------
        # Layout
        self.logFormLayout = QFormLayout(self)
        self.logTab.setLayout(self.logFormLayout)
        # Email ROW
        self.lEmaLbl = QLabel("Email: ")
        self.lEmaTxt = QLineEdit(self)
        self.lEmaTxt.setPlaceholderText("E-mail")
        self.logFormLayout.addRow(self.lEmaLbl, self.lEmaTxt)
        # Password Row
        self.lPasLbl = QLabel("Password: ")
        self.lPasTxt = QLineEdit(self.logTab)
        self.lPasTxt.setInputMask("")
        self.lPasTxt.setEchoMode(QLineEdit.Password)
        self.lPasTxt.setReadOnly(False)
        self.lPasTxt.setClearButtonEnabled(False)
        self.lPasTxt.setPlaceholderText("Password")
        self.logFormLayout.addRow(self.lPasLbl, self.lPasTxt)
        # Combo Box Row
        self.lWhoLog = QLabel("Who login: ")
        self.lwhoComBox = QComboBox(self)
        self.lwhoComBox.addItem("Customer")
        self.lwhoComBox.addItem("Driver")
        self.lwhoComBox.addItem("Administrator")
        self.logFormLayout.addRow(self.lWhoLog, self.lwhoComBox)
        # Login button Row
        self.LoginButton = QPushButton("Login")
        self.logFormLayout.addRow(self.LoginButton)

        # CREATE REGISTRATION TAB-------------------------------------------
        # Layout
        self.regFormLayout = QFormLayout(self)
        self.regTab.setLayout(self.regFormLayout)
        # Forename Row
        self.rForLbl = QLabel("Forename: ")
        self.rForTxt = QLineEdit(self)
        self.rForTxt.setPlaceholderText("Forename")
        self.regFormLayout.addRow(self.rForLbl, self.rForTxt)
        # Surname Row
        self.rSurLbl = QLabel("Surname: ")
        self.rSurTxt = QLineEdit(self)
        self.rSurTxt.setPlaceholderText("Surname")
        self.regFormLayout.addRow(self.rSurLbl, self.rSurTxt)
        # Email Row
        self.rEmaLbl = QLabel("Email: ")
        self.rEmaTxt = QLineEdit(self)
        self.rEmaTxt.setPlaceholderText("E-mail address")
        self.regFormLayout.addRow(self.rEmaLbl, self.rEmaTxt)
        # Password Row
        self.rPasLbl = QLabel("Password: ")
        self.rPasTxt = QLineEdit(self.logTab)
        self.rPasTxt.setInputMask("")
        self.rPasTxt.setEchoMode(QLineEdit.Password)
        self.rPasTxt.setReadOnly(False)
        self.rPasTxt.setClearButtonEnabled(False)
        self.rPasTxt.setPlaceholderText("Password")
        self.regFormLayout.addRow(self.rPasLbl, self.rPasTxt)
        # Confirm Password Row
        self.rConPasLbl = QLabel("Confirm password: ")
        self.rConPasTxt = QLineEdit(self.logTab)
        self.rConPasTxt.setInputMask("")
        self.rConPasTxt.setEchoMode(QLineEdit.Password)
        self.rConPasTxt.setReadOnly(False)
        self.rConPasTxt.setClearButtonEnabled(False)
        self.rConPasTxt.setPlaceholderText("Confirm password")
        self.regFormLayout.addRow(self.rConPasLbl, self.rConPasTxt)
        # Preferred payment Row
        self.rPrePay = QLabel("Payment method: ")
        self.rPrePayBox = QComboBox(self)
        self.rPrePayBox.addItem("Online card")
        self.rPrePayBox.addItem("Card in car")
        self.rPrePayBox.addItem("Cash in car")
        self.regFormLayout.addRow(self.rPrePay, self.rPrePayBox)
        # Registration button Row
        self.RegistrationButton = QPushButton("Registration")
        self.regFormLayout.addRow(self.RegistrationButton)



        # Add tabs to widget
        self.layout.addWidget(self.tabs)
        self.setLayout(self.layout)

        self.RegistrationButton.clicked.connect(self.on_click)

    # @pyqtSlot()
    def on_click(self):
        print(self.lPasTxt.text())


if __name__ == '__main__':
    app = QApplication(sys.argv)
    ex = App()
    sys.exit(app.exec_())
Editor is loading...