-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrid_test.py
More file actions
37 lines (27 loc) · 1.04 KB
/
Copy pathgrid_test.py
File metadata and controls
37 lines (27 loc) · 1.04 KB
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
import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QLineEdit, QLabel, QGridLayout
from PyQt5.QtCore import Qt
class MainWindow(QWidget):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.setWindowTitle('Login Form')
# set the grid layout
layout = QGridLayout()
self.setLayout(layout)
# username
layout.addWidget(QLabel('Username:'), 0, 0)
layout.addWidget(QLineEdit(), 0, 1)
# password
layout.addWidget(QLabel('Password:'), 1, 0)
layout.addWidget(QLineEdit(echoMode=QLineEdit.EchoMode.Password), 1, 1)
# buttons
layout.addWidget(QPushButton('Log in'), 2, 0,
alignment=Qt.AlignmentFlag.AlignRight)
layout.addWidget(QPushButton('Close'), 2, 1,
alignment=Qt.AlignmentFlag.AlignRight)
# show the window
self.show()
if __name__ == '__main__':
app = QApplication(sys.argv)
window = MainWindow()
sys.exit(app.exec())