-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGUI PyQt5.py
44 lines (33 loc) · 1.14 KB
/
GUI PyQt5.py
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
from PyQt5.QtWidgets import *
class Widgets(QWidget):
def __init__(self):
super(Widgets, self).__init__()
self.vlayout = QVBoxLayout()
self.hlayout1 = QHBoxLayout()
self.l1 = QLabel()
self.l1.setText('Enter your name')
self.hlayout1.addWidget(self.l1)
self.t1 = QLineEdit()
self.hlayout1.addWidget(self.t1)
self.vlayout.addLayout(self.hlayout1)
self.hlayout2 = QHBoxLayout()
self.l2 = QLabel()
self.l2.setText('Enter your age')
self.hlayout2.addWidget(self.l2)
self.t2 = QLineEdit()
self.hlayout2.addWidget(self.t2)
self.vlayout.addLayout(self.hlayout2)
self.bttn = QPushButton('Submit')
self.bttn.clicked.connect(self.onclick)
self.vlayout.addWidget(self.bttn)
self.setLayout(self.vlayout)
def onclick(self):
print(f'My name is {self.t1.text()} and age is {self.t2.text()}')
def window():
app = QApplication([])
wig = Widgets()
wig.setWindowTitle('PyQt5')
wig.show()
app.exec_()
if __name__ == '__main__':
window()