I'm fiddling around with a piece of python code to use with form validation. It works fine, but the real problem is that QGIS refuses to acknowledge the changes I make in the script.
Here's what I did:
- created the .py
- referenced it in "layer Properties - Fields - Python init function"
- it works as expected, popping up the message box saying CHEESE
- now I open the py file in an editor, and change the message to MOUSE and save/close the editor
- QGIS now still says CHEESE. I either have to restart QGIS or rename the file and reference it again, which is obviously a massive waste of time.
How can this be fixed?
from PyQt4.QtCore import * from PyQt4.QtGui import * nameField = None myDialog = None def formOpen(dialog,layerid,featureid): global myDialog myDialog = dialog global nameField nameField = dialog.findChild(QLineEdit,"Name") buttonBox = dialog.findChild(QDialogButtonBox,"buttonBox") # Disconnect the signal that QGIS has wired up for the dialog to the button box. buttonBox.accepted.disconnect(myDialog.accept) # Wire up our own signals. buttonBox.accepted.connect(validate) buttonBox.rejected.connect(myDialog.reject) def validate(): # Make sure that the name field isn't empty. msgBox = QMessageBox() msgBox.setText("MOUSE") msgBox.exec_()