简体   繁体   中英

pyqt4 how to know textEdit field is empty

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) == ""

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM