Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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
add comment

1 Answer 1

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: [qgisworkshop.org/html/workshop/plugins_tutorial.html] (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() self.dlg.show(). –  Nils Apr 13 '13 at 11:39
add comment

Your Answer

 
discard

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.