pyqt4 how to know textEdit field is empty
Question:
I want to know if textbox is empty or not. So, I made this code. But, if self.row is ‘ ‘ <- this is not working. Although, textEdit field is empty but, it’s not recognize.
def setUi(self):
self.textEdit = QtGui.QTextEdit(MainWindow)
self.textEdit.setGeometry(QtCore.QRect(155, 90, 471, 31))
self.textEdit.setObjectName(_fromUtf8("textEdit"))
def bringcolumn(self):
self.row = self.textEdit.toPlainText()
if self.row is '': #I want to know if self.row is empty of not.
QtGui.QMessageBox.information(self, "Message", "ERROR")
Answers:
Change if self.row is ''
to if str(self.row) == ""
I want to know if textbox is empty or not. So, I made this code. But, if self.row is ‘ ‘ <- this is not working. Although, textEdit field is empty but, it’s not recognize.
def setUi(self):
self.textEdit = QtGui.QTextEdit(MainWindow)
self.textEdit.setGeometry(QtCore.QRect(155, 90, 471, 31))
self.textEdit.setObjectName(_fromUtf8("textEdit"))
def bringcolumn(self):
self.row = self.textEdit.toPlainText()
if self.row is '': #I want to know if self.row is empty of not.
QtGui.QMessageBox.information(self, "Message", "ERROR")
Change if self.row is ''
to if str(self.row) == ""