I have a question regarding adding a warning popup when a user pressed OK while forgetting to fill in all the required fields in the plugin dialog. I have the following definition which checks if all fields contain text:
def inputCheck(self):
if self.dlg.lineEdit_dxf.text() == "":
QMessageBox.information(None, "Warning!", "Select a .dxf file" )
return False
return True
I thought that by adding the following code (see below) in the "def run(self)" part of the script the dialog would not close when the user presses OK. However, while the popup works fine and the script does not run, the dialog still closes down.
def run(self):
self.dlg.show()
result = self.dlg.exec_()
if result:
if not self.inputCheck():
return
#rest of script#
I built my plugin with the help of the plugin builder and I have not changed the overall layout of the script.