Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
without pressing any buttons.I wonder how you will change the contents of the LineEdit, telepathically? ¯\_(ツ)_/¯
import sys
from PySide2.QtCore import Qt
from PySide2.QtWidgets import (QApplication, QWidget,
QPushButton, QLabel, QVBoxLayout, QLineEdit)
class MyWidget(QWidget):
def __init__(self):
QWidget.__init__(self)
self.my_label = QLabel()
self.line_edit = QLineEdit()
self.my_label.setAlignment(Qt.AlignCenter)
self.layout = QVBoxLayout()
self.layout.addWidget(self.my_label)
self.layout.addWidget(self.line_edit)
self.setLayout(self.layout)
self.line_edit.textChanged.connect(self.magic) # Реагируем на события изменения текста
def magic(self):
self.my_label.setText(self.line_edit.text()) # Выводим в label текст из lineedit
if __name__ == "__main__":
app = QApplication(sys.argv)
widget = MyWidget()
widget.resize(200, 150)
widget.show()
sys.exit(app.exec_())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question