I've read many threads on this but I'm not able to figure out the solution (I'm a beginner to the plugin creation...).
What I what to do is to close the dialog window when the algorithm has finished its job.
That's the piece of code of the alg.dialog.py
:
class CreateModelDialog(QDialog, FORM_CLASS):
def __init__(self, iface):
QDialog.__init__(self)
self.iface = iface
self.setupUi(self)
self.buttonBox.rejected.connect(self.reject)
self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect(self.createModel)
self.manageGui()
........
def createModel(self):
modelName = self.bxDBname.text()
modelType = self.cmbBxModelType.currentText()
lengthString = self.cmbBxLengthUnit.currentText()
timeString = self.cmbBxTimeUnit.currentText()
workingDir = self.OutFilePath
print 'Direttori recuperata ..... ' , workingDir
isChild = 1.0
createModel(modelName, workingDir, modelType, isChild, lengthString, timeString)
So self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect(self.createModel)
, when clicked runs the createModel
method.
But the dialog remains opended, where should I edit the code?
This is the __init__
function:
def __init__(self, iface):
QDialog.__init__(self)
self.iface = iface
self.setupUi(self)
self.buttonBox.rejected.connect(self.reject)
self.buttonBox.button(QDialogButtonBox.Ok).clicked.connect(self.createModel)
self.manageGui()
This is the function in the main plugin.py
file:
def runCreateModel(self):
"""Run method that performs all the real work"""
# Create the dialog (after translation) and keep reference
self.dlgMD = mdDialog.CreateModelDialog(self.iface)
# show the dialog
self.dlgMD.show()
# Run the dialog event loop
self.dlgMD.exec_()