1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 | import sys from PyQt5.QtWidgets import * from PyQt5.QtGui import * class LogInDialog(QDialog): def __init__(self): super().__init__() self.setupUI() self.id = None self.password = None def setupUI(self): self.setGeometry(1100, 200, 300, 100) self.setWindowTitle("Sign In") self.setWindowIcon(QIcon('icon.png')) label1 = QLabel("ID: ") label2 = QLabel("Password: ") self.lineEdit1 = QLineEdit() self.lineEdit2 = QLineEdit() self.pushButton1= QPushButton("Sign In") self.pushButton1.clicked.connect(self.pushButtonClicked) layout = QGridLayout() layout.addWidget(label1, 0, 0) layout.addWidget(self.lineEdit1, 0, 1) layout.addWidget(self.pushButton1, 0, 2) layout.addWidget(label2, 1, 0) layout.addWidget(self.lineEdit2, 1, 1) self.setLayout(layout) def pushButtonClicked(self): self.id = self.lineEdit1.text() self.password = self.lineEdit2.text() self.close() class MyWindow(QWidget): def __init__(self): super().__init__() self.setupUI() def setupUI(self): self.setGeometry(800, 200, 300, 300) self.setWindowTitle("PyStock v0.1") self.setWindowIcon(QIcon('icon.png')) self.pushButton = QPushButton("Sign In") self.pushButton.clicked.connect(self.pushButtonClicked) self.label = QLabel() layout = QVBoxLayout() layout.addWidget(self.pushButton) layout.addWidget(self.label) self.setLayout(layout) def pushButtonClicked(self): dlg = LogInDialog() dlg.exec_() id = dlg.id password = dlg.password self.label.setText("id: %s password: %s" % (id, password)) if __name__ == "__main__": app = QApplication(sys.argv) window = MyWindow() window.show() app.exec_() | cs |
'PY QT' 카테고리의 다른 글
pyqt ui 기본 템플릿 (0) | 2019.03.04 |
---|---|
pyqt .ui파일 .py로 변환 (0) | 2019.03.04 |
vs code 파이썬 설정 (0) | 2019.03.03 |
pyqt 튜토리얼 (0) | 2019.03.03 |