Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
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

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.

share|improve this answer
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 posting your answer, you agree to the privacy policy and terms of service.

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