def submitContact(self):
name = self.nameLine.text()
address = self.addressText.toPlainText()
if name == "" or address == "":
QMessageBox.information(self, "Empty Field",
"Please enter a name and address.")
return
if name not in self.contacts:
self.contacts[name] = address
QMessageBox.information(self, "Add Successful",
"\"%s\" has been added to your address book." % name)
else:
QMessageBox.information(self, "Add Unsuccessful",
"Sorry, \"%s\" is already in your address book." % name)
return
if not self.contacts:
self.nameLine.clear()
self.addressText.clear()
self.nameLine.setReadOnly(True)
self.addressText.setReadOnly(True)
self.addButton.setEnabled(True)
self.submitButton.hide()
self.cancelButton.hide()
评论列表
文章目录