2

I'm writing a QGIS conversion plugin in python to be able to create Obstacle-files for a model from shapefiles.

What I want to do now is just to close the plugin cleanly. This means, to close the GUI, to delete the variables and so on. I tried to use sys.exit(), but it also closes QGIS.

How do I only close the plugin?

  • Consider using an object-oriented approach while coding your plugin. If you create your dialog and your (nested) functions as object, you can just delete (del) the whole object after computations finished. – Curlew Jun 17 '13 at 21:45
1

If you are using a subclass of QWidget (e.g. a QDialog or QMainWindow) you can simply call the widget's close or hide method. If you want to free memory used by your variables you can delete them with del or set them to None and they will be garbage collected.

  • Hm, this does to close the GUI. Thanks for that! But for the variables, there has to be an easier way. I have some dozens of variables, that are created or not depending on different conditions. I would have to check for any of them if it was created and delete it or not...? – dom Apr 19 '13 at 6:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.