PyQt5 文本框
单行文本输入框(QLineEdit)
import sys from PyQt5.QtWidgets import QApplication, QWidget, QLineEdit, QLabel class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.resize(250, 155) self.setWindowTitle('title') # 实例化QLineEdit对象 self.line_edit = QLineEdit(self) # 实例化QLabel对象 self.label = QLabel(self) # 设置标签的位置和大小 self.label.setGeometry(0, 30, 200, 20) # 连接信号和槽 self.line_edit.textChanged.connect(self.label.setText) self.show() if __name__ == "__main__": app = QApplication(sys.argv) ex = Example() sys.exit(app.exec_())