Skip to content

Commit

Permalink
added tooltip support
Browse files Browse the repository at this point in the history
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@138 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
  • Loading branch information
volayaf@gmail.com committed Apr 21, 2012
1 parent db7d7f6 commit 3fd0697
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
7 changes: 7 additions & 0 deletions src/sextante/core/GeoAlgorithm.py
Expand Up @@ -69,6 +69,13 @@ def getCustomModelerParametersDialog(self, modelAlg):
it should be returned here, ready to be executed'''
return None

def getParameterDescriptions(self):
'''Returns a dict with param names as keys and detailed descriptions of each param
as value. These descriptions are used as tool tips in the parameters dialog.
If a description does not exist, the parameter's human-readable name is used'''
descs = {}
return descs

def checkBeforeOpeningParametersDialog(self):
'''If there is any check to perform before the parameters dialog is opened,
it should be done here. This method returns an error message string if there
Expand Down
23 changes: 22 additions & 1 deletion src/sextante/grass/GrassAlgorithm.py
Expand Up @@ -41,10 +41,31 @@ def getIcon(self):
def helpFile(self):
folder = GrassUtils.grassHelpPath()
if str(folder).strip() != "":
helpfile = str(folder) + os.sep + self.name + ".html"
helpfile = str(folder) + os.sep + self.grassName + ".html"
return helpfile
return None

def getParameterDescriptions(self):
descs = {}
helpfile = self.helpFile()
if helpfile:
try:
infile = open(helpfile)
lines = infile.readlines()
for i in range(len(lines)):
if lines[i].startswith("<DT><b>"):
for param in self. parameters:
searchLine = "<b>" + param.name + "</b>"
if searchLine in lines[i]:
i+=1
descs[param.name] = lines[i][4:-6]
break

infile.close()
except Exception:
pass
return descs

def defineCharacteristicsFromFile(self):
lines = open(self.descriptionFile)
line = lines.readline().strip("\n").strip()
Expand Down
7 changes: 7 additions & 0 deletions src/sextante/gui/ParametersPanel.py
Expand Up @@ -40,6 +40,7 @@ def __init__(self, alg, paramDialog):
self.initGUI()

def initGUI(self):
tooltips = self.alg.getParameterDescriptions()
tableLike = SextanteConfig.getSetting(SextanteConfig.TABLE_LIKE_PARAM_PANEL)
if tableLike:
self.tableWidget = QtGui.QTableWidget()
Expand Down Expand Up @@ -83,6 +84,12 @@ def initGUI(self):
QtCore.QObject.connect(button, QtCore.SIGNAL("toggled(bool)"), self.buttonToggled)
widget = QtGui.QWidget()
widget.setLayout(layout)
if param.name in tooltips.keys():
tooltip = tooltips[param.name]
else:
tooltip = param.description
label.setToolTip(tooltip)
widget.setToolTip(tooltip)
self.verticalLayout.addWidget(label)
self.verticalLayout.addWidget(widget)

Expand Down

0 comments on commit 3fd0697

Please sign in to comment.