I've got a QLineEdit field and a QPushButton. The button should be disabled as long the QLineEdit is empty.
How to do that?
I've got a QLineEdit field and a QPushButton. The button should be disabled as long the QLineEdit is empty.
How to do that?
well, i'll just conclude what they said in the comments, some code like
self.btnButton.setDisable(True)
self.leInput.textChanged.connect(self.disableButton)
def disableButton(self):
if len(self.leInput.text()) > 0:
self.btnButton.setDisable(False)
and yes, the signals / function names are obvious, you need to check more on the docs / tutor
Here is a one-liner solution:
self.textBox.textChanged[str].connect(lambda: self.myBtn.setEnabled(self.textBox.text() != ""))
You still have to set the initial state of the button to False. You can do that in the declaration though. e.g.
self.myBtn = QtGui.QPushButton("My Button", enabled=False)