-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path05 Form Layouts.py
More file actions
43 lines (30 loc) · 946 Bytes
/
Copy path05 Form Layouts.py
File metadata and controls
43 lines (30 loc) · 946 Bytes
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
import sys
import PyQt5.QtWidgets as qtw
import PyQt5.QtGui as qtg
class MainWindow(qtw.QWidget):
def __init__(self):
super(MainWindow, self).__init__()
self.setWindowTitle("Hello World!")
# Set QForm Layout
layout = qtw.QFormLayout()
self.setLayout(layout)
# Widgets
lab = qtw.QLabel("Label Row")
lab.setFont(qtg.QFont("Arial", 20))
fName = qtw.QLineEdit()
lName = qtw.QLineEdit()
def submit():
lab.setText(f"Hello {fName.text()} {lName.text()}!")
fName.setText("")
lName.setText("")
# Create a Button
btn = qtw.QPushButton("Submit", clicked=submit)
# Add rows
layout.addRow(lab)
layout.addRow("F name", fName)
layout.addRow("L name", lName)
layout.addRow(btn)
self.show()
app = qtw.QApplication([])
mw = MainWindow()
sys.exit(app.exec_())