pyqt 实时获取input的值


# -*- coding: utf-8 -*-
from PyQt4.QtGui import *
import sys
class event(QWidget):
    def __init__(self):
        super(event, self).__init__()
        self.setup_frame()
    def setup_frame(self):
        self.setWindowTitle(u"时时获取input的值")
        self.input_text = QLineEdit()
        self.input_text.setText(u'aa')
        self.btn=QPushButton(u'确定')
        self.btn.setVisible(False)
        bl = QHBoxLayout()
        bl.addWidget(self.input_text)
        bl.addWidget(self.btn)
        self.setLayout(bl)
        self.input_text.textChanged.connect(self.display)

    def display(self):
        input_value=str(self.input_text.text())
        if input_value=='love':
            self.btn.setVisible(True)

app=QApplication(sys.argv)
enterEvent=event()
enterEvent.show()
app.exec_()

pyqt 实时获取input的值

你可能感兴趣的:(PyQt)