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 am currently taking my first steps in playing around with programming a plugin in python 2.7 for QGIS 1.8. While my plugin does what it should, I would like to make it more userfriendly. At the moment, the user is expected to choose an input- and an output-file, which are then processed. In case the user forgets to choose one (or both) of the files, the plugin is displaying an information window - and then quits completely after the user hits "OK".

if src_filepath =="" and dst_filepath =="":
    QMessageBox.information(None, "DEBUG:","Please specify files!")`

However, I would rather like to reload the main plugin-window with the "choose file"-dialog. I suspect that the solution is rather easy, but I was not able to invoke this window, so any help is appreciated. The interface code derives more or less directly from the "Plugin Builder" in QGIS.

share|improve this question

I don't know how you coded your plugin, but if you encapsuled your dialog inside a class structure, than you could just invoke it again (create a new object).

If you just want to get an "OpenFileDialog" you can create it like this:

fileName = QFileDialog.getOpenFileName( self, "title","lastUsedDir", "SHP files (*.shp *.SHP)" )
share|improve this answer
Thanks for the input! The solution turned out to be very easy, as I found out with the help of this tutorial: [] (there is also the template of the "Plugin Builder" linked). All I had to do was to end the if-Message with self.dlg = PluginDialog() – Nils Apr 13 '13 at 11:39

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.