class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel('Ubuntu', self) combo = QComboBox(self) combo.addItem('Ubuntu') combo.addItem('Mandriva') combo.addItem('Fedora') combo.addItem('Arch') combo.addItem('Gentoo') combo.move(50, 50) self.lbl.move(50, 150) combo.textActivated[str].connect(self.onActivated) self.setGeometry(300, 300, 450, 400) self.setWindowTitle('QComboBox') self.show() def onActivated(self, text): self.lbl.setText(text) self.lbl.adjustSize()
class Example(QWidget): def __init__(self): super().__init__() self.initUI() def initUI(self): self.lbl = QLabel(self) qle = QLineEdit(self) qle.move(60, 100) self.lbl.move(60, 40) qle.textChanged[str].connect(self.onChanged) self.setGeometry(300, 300, 350, 250) self.setWindowTitle('QLineEdit') self.show() def onChanged(self, text): self.lbl.setText(text) self.lbl.adjustSize()