728x90
반응형
import sys
from PySide2.QtWidgets import (QApplication, QWidget, QLabel, QGridLayout,
                               QLineEdit, QPushButton, QHBoxLayout,
                               QVBoxLayout)

from PySide2.QtGui import QIcon
from PySide2.QtCore import Qt

if __name__ == "__main__":
    
    app = QApplication(sys.argv)
    login = QWidget()
    
    labelId = QLabel("Id: ")
    labelId.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
    labelPW = QLabel("Password: ")
    
    lineEditId = QLineEdit()
    lineEditPW = QLineEdit()
    lineEditPW.setEchoMode(QLineEdit.Password)
    
    labelId.setBuddy(lineEditId)
    labelPW.setBuddy(lineEditPW)
    
    buttonOk = QPushButton("Ok")
    buttonOk.setIcon(QIcon())
    
    layout1 = QGridLayout()
    layout1.addWidget(labelId,0,0)
    layout1.addWidget(lineEditId,0,1);
    layout1.addWidget(labelPW,1,0)
    layout1.addWidget(lineEditPW,1,1)

    layout2 = QHBoxLayout()
    layout2.addStretch()
    layout2.addWidget(buttonOk)

    mainLayout = QVBoxLayout()
    mainLayout.addLayout(layout1)
    mainLayout.addLayout(layout2)

    login.setLayout(mainLayout)
    login.setWindowTitle('Log on')
    login.setWindowIcon(QIcon(":/images/ok.png"))  # 

    buttonOk.clicked.connect(app.quit)

    login.show()
    app.exec_()
728x90
반응형

'Qt' 카테고리의 다른 글

login  (0) 2022.11.04
QPushbutton exam..  (0) 2022.11.03
Python Serial Write Qt  (0) 2022.11.01
Serial Communication (from Arduino to Python)  (0) 2022.11.01
qt_groupbox_frame.py  (0) 2022.10.28

+ Recent posts