Skip to content

Commit 3fd0697

Browse files
author
volayaf@gmail.com
committed
added tooltip support
git-svn-id: http://sextante.googlecode.com/svn/trunk/soft/bindings/qgis-plugin@138 881b9c09-3ef8-f3c2-ec3d-21d735c97f4d
1 parent db7d7f6 commit 3fd0697

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

src/sextante/core/GeoAlgorithm.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ def getCustomModelerParametersDialog(self, modelAlg):
6969
it should be returned here, ready to be executed'''
7070
return None
7171

72+
def getParameterDescriptions(self):
73+
'''Returns a dict with param names as keys and detailed descriptions of each param
74+
as value. These descriptions are used as tool tips in the parameters dialog.
75+
If a description does not exist, the parameter's human-readable name is used'''
76+
descs = {}
77+
return descs
78+
7279
def checkBeforeOpeningParametersDialog(self):
7380
'''If there is any check to perform before the parameters dialog is opened,
7481
it should be done here. This method returns an error message string if there

src/sextante/grass/GrassAlgorithm.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,31 @@ def getIcon(self):
4141
def helpFile(self):
4242
folder = GrassUtils.grassHelpPath()
4343
if str(folder).strip() != "":
44-
helpfile = str(folder) + os.sep + self.name + ".html"
44+
helpfile = str(folder) + os.sep + self.grassName + ".html"
4545
return helpfile
4646
return None
4747

48+
def getParameterDescriptions(self):
49+
descs = {}
50+
helpfile = self.helpFile()
51+
if helpfile:
52+
try:
53+
infile = open(helpfile)
54+
lines = infile.readlines()
55+
for i in range(len(lines)):
56+
if lines[i].startswith("<DT><b>"):
57+
for param in self. parameters:
58+
searchLine = "<b>" + param.name + "</b>"
59+
if searchLine in lines[i]:
60+
i+=1
61+
descs[param.name] = lines[i][4:-6]
62+
break
63+
64+
infile.close()
65+
except Exception:
66+
pass
67+
return descs
68+
4869
def defineCharacteristicsFromFile(self):
4970
lines = open(self.descriptionFile)
5071
line = lines.readline().strip("\n").strip()

src/sextante/gui/ParametersPanel.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ def __init__(self, alg, paramDialog):
4040
self.initGUI()
4141

4242
def initGUI(self):
43+
tooltips = self.alg.getParameterDescriptions()
4344
tableLike = SextanteConfig.getSetting(SextanteConfig.TABLE_LIKE_PARAM_PANEL)
4445
if tableLike:
4546
self.tableWidget = QtGui.QTableWidget()
@@ -83,6 +84,12 @@ def initGUI(self):
8384
QtCore.QObject.connect(button, QtCore.SIGNAL("toggled(bool)"), self.buttonToggled)
8485
widget = QtGui.QWidget()
8586
widget.setLayout(layout)
87+
if param.name in tooltips.keys():
88+
tooltip = tooltips[param.name]
89+
else:
90+
tooltip = param.description
91+
label.setToolTip(tooltip)
92+
widget.setToolTip(tooltip)
8693
self.verticalLayout.addWidget(label)
8794
self.verticalLayout.addWidget(widget)
8895

0 commit comments

Comments
 (0)