Check out Kite (free AI Coding Assistant) → Link

Buy Me a Coffee? Your support is much appreciated!

PayPal Me: https://www.paypal.me/jiejenn/5
Venmo: @Jie-Jenn

Source Code:

import sys
from PyQt6.QtWidgets import QApplication, QWidget, QLineEdit, QHBoxLayout, QVBoxLayout
from PyQt6.QtCore import Qt

class MyApp(QWidget):
    def __init__(self):
        super().__init__()
        self.window_width, self.window_height = 700, 500
        self.resize(self.window_width, self.window_height)

        layout = QVBoxLayout()
        self.setLayout(layout)

        lineEdits = {}

        lineEdits['NoEcho'] = QLineEdit()
        lineEdits['NoEcho'].setPlaceholderText('No Echo')
        lineEdits['NoEcho'].setEchoMode(QLineEdit.EchoMode.NoEcho)
        lineEdits['NoEcho'].textChanged.connect(self.printValue)

        lineEdits['Normal'] = QLineEdit()
        lineEdits['Normal'].setPlaceholderText('Normal')
        lineEdits['Normal'].setEchoMode(QLineEdit.EchoMode.Normal)
        lineEdits['Normal'].textChanged.connect(self.printValue)

        lineEdits['Password'] = QLineEdit()
        lineEdits['Password'].setPlaceholderText('Password')
        lineEdits['Password'].setEchoMode(QLineEdit.EchoMode.Password)
        lineEdits['Password'].textChanged.connect(self.printValue)

        lineEdits['PasswordEchoOnEdit'] = QLineEdit()
        lineEdits['PasswordEchoOnEdit'].setPlaceholderText('PasswordEchoOnEdit')
        lineEdits['PasswordEchoOnEdit'].setEchoMode(QLineEdit.EchoMode.PasswordEchoOnEdit)
        lineEdits['PasswordEchoOnEdit'].textChanged.connect(self.printValue)                

        for _, item in lineEdits.items():
            layout.addWidget(item)

    def printValue(self, v):
        print(v)

if __name__ == '__main__':
    # don't auto scale when drag app to a different monitor.
    # QGuiApplication.setHighDpiScaleFactorRoundingPolicy(Qt.HighDpiScaleFactorRoundingPolicy.PassThrough)
    
    app = QApplication(sys.argv)
    app.setStyleSheet('''
        QWidget {
            font-size: 17px;
        }
    ''')
    
    myApp = MyApp()
    myApp.show()

    try:
        sys.exit(app.exec())
    except SystemExit:
        print('Closing Window...')