# cPy qt_intro : line edit
# Copyright by Anthony Vogelaar, Perth Scotland
# rev 0.10  2026-01-26  initial release

from    PySide6.QtWidgets   import  QApplication, QWidget, QPushButton, QLineEdit

# ========================== demo ==============================

# demonstrating QLineEdit
class Gui1(QWidget):

    def __init__(self):
        app = QApplication()                            # Qt framework
        super().__init__()                              # instantiate QWidget = GUI
        self.resize(550, 150)
        self.ed1 = QLineEdit('Enter text', self)
        self.ed1.setGeometry(50, 50, 180, 30)
        self.ed1.textChanged.connect(self.onChanged)
        btn = QPushButton('Copy', self) # space between icon and text
        btn.setGeometry(250, 50, 50, 30)
        btn.clicked.connect(self.onBtnClick)
        self.ed2 = QLineEdit('Read only', self)
        self.ed2.setGeometry(320, 50, 180, 30)
        self.ed2.setReadOnly(True)
        self.ed2.setStyleSheet('background-color: MediumAquamarine')
        self.show()
        app.exec()


    def onChanged(self):
        self.ed1.setStyleSheet('background-color: Yellow')


    def onBtnClick(self, sts):
        self.ed2.setText(self.ed1.text())
        self.ed1.clear()
        self.ed1.setStyleSheet('background-color: White')

# ============================= main =============================

Gui1()

# ============================== end =============================
