-
Notifications
You must be signed in to change notification settings - Fork 0
/
PyQt5_QLineEditWidget.py
58 lines (40 loc) · 1.13 KB
/
PyQt5_QLineEditWidget.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import sys
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
def window():
app = QApplication(sys.argv)
win = QWidget()
e1 = QLineEdit()
e1.setValidator(QIntValidator())
e1.setMaxLength(8)
e1.setAlignment(Qt.AlignRight)
e1.setFont(QFont("Arial", 20))
e2 = QLineEdit()
e2.setValidator(QDoubleValidator(0.99, 99.99, 2))
flo = QFormLayout()
flo.addRow("integer validator", e1)
flo.addRow("Double validator", e2)
e3 = QLineEdit()
e3.setInputMask('+99_9999_999999')
flo.addRow("Input Mask", e3)
e4 = QLineEdit()
e4.textChanged.connect(textchanged)
flo.addRow("Text changed", e4)
e5 = QLineEdit()
e5.setEchoMode(QLineEdit.Password)
flo.addRow("Password", e5)
e6 = QLineEdit("Hello Python")
e6.setReadOnly(True)
flo.addRow("Read Only", e6)
e5.editingFinished.connect(enterPress)
win.setLayout(flo)
win.setWindowTitle("PyQt")
win.show()
sys.exit(app.exec_())
def textchanged(text):
print("contents of text box: " + text)
def enterPress():
print("edited")
if __name__ == '__main__':
window()