Install
Sextante is in the official plugin repository.
Go to Plugins => Fetch Plugins, look for Sextante in the list, select it and click install.
In case it is not in the list, the main repository is probably missing. Go to the Repositories tab and add the following URL:
http://plugins.qgis.org/plugins/plugins.xml
Proxy Settings
In case there are still not all plugins showing up, make sure, that the proxy settings in Settings => Options => Network are properly set up.
Enable
You also have to make sure it is enabled. Go to Plugins => Manage Plugins, and tick the Sextante entry in the list.
Newer version
The latest version for QGIS 1.8 is from January 2013. Since then, a lot of improvement has been made, but is only available with the current Nightly (aka master, 1.9, 2.0) and is there installed by default. Be aware that this is an unstable version of QGIS but may bring improvements.
To achieve this, you'll have to change the default code, both in the .ui
and in the main python file. Basically, you have to use signals to catch the click
event on your OK button.
First thing first: in your XX_dialog_base.ui
file, replace the QDialogButtonBox
object (which contains the "OK" and "Cancel" buttons) with 2 simple QPushButton
objects. Let's say that the "OK" Push Button is called runButton
(in QT Designer, you can set the name of an object in the right panel).
Then, the main work: in your main .py
file, you have to import pyqtSignal
and pyqtSlot
(from PyQt4.QtCore import pyqtSignal, pyqtSlot
). To display a message box, you also have to import QMessageBox
(from PyQt4.QtGui import QMessageBox
).
Your run
method should simply look like this:
def run(self):
"""Run method that performs all the real work"""
# add some code to preset the GUI if needed
self.dlg.runButton.setEnabled(True)
# show the dialog
self.dlg.show()
# Run the dialog event loop
self.dlg.exec_()
At the beginning of the __init__
method, add the following line: super(XXX, self).__init__()
(don't ask me why, it just won't work otherwise). Replace XXX
with the name of your class (which is usually the name of your plugin).
In the initGui
method, add (wherever) the following line: self.dlg.runButton.clicked.connect( self.onStart )
. This will connect the "clicked on runButton" event to the onStart
method, which will look like this (you can write it wherever you want):
@pyqtSlot()
def onStart(self):
# here you can do whatever you want before running the main code
# for example, display a message under some condition:
if wrongOptions:
messageBox = QMessageBox()
messageBox.setWindowTitle( "Title" )
messageBox.setText( "Content" )
messageBox.setIcon( QMessageBox.Critical )
messageBox.exec_()
return
else:
self.dlg.runButton.setEnabled(False) # Disable OK button
self.dlg.closeButton.setEnabled(False) # Disable cancel button
self.main() # Run main function
You may need to add some changes to what I wrote, but this should cover most of what you want. Note that with this approach (events and signals), you can event control the options before the user clicks on OK (no need for warning messages).
Bonus links:
Best Answer
Plugins are written in Python, so use a Python debugger as pdb present in the standard distribution
and look Python module of the week: pdb – Interactive Debugger, Debugging in Python or the multiple tutorials on the Web.
Or choose another one of those presented in Python Debugging Tools