-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path01 input box.py
More file actions
42 lines (28 loc) · 929 Bytes
/
Copy path01 input box.py
File metadata and controls
42 lines (28 loc) · 929 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
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 Vertical Layout
self.setLayout(qtw.QVBoxLayout())
# Label
lab = qtw.QLabel("Whats Your Name?")
lab.setFont(qtg.QFont("Arial", 20))
self.layout().addWidget(lab)
# input entry box
entry = qtw.QLineEdit()
entry .setObjectName("Name_field")
# entry.setText("") # placeholder
self.layout().addWidget(entry)
def submit():
lab.setText(f"Hello {entry.text()}!")
entry.setText("")
# Create a Button
btn = qtw.QPushButton("Submit", clicked=submit)
self.layout().addWidget(btn)
self.show()
app = qtw.QApplication([])
mw = MainWindow()
sys.exit(app.exec_())