[Qgis-developer] Executing Action on click
Karl D
karl.determe at gmail.com
Wed Aug 4 05:45:30 EDT 2010
Hi all
I would like to implement a python plugin consisting on the following
control:
when the control is activated, the user could click on a feature to
immediatly execute an action defined in the current layer.
I thought to use something like this:
def run(self):
mapCanvas=self.iface.mapCanvas()
# Create the appropriate map tool and connect the gotPoint()
signal.
self.emitPoint = QgsMapToolEmitPoint(mapCanvas)
mapCanvas.setMapTool(self.emitPoint)
QObject.connect(self.emitPoint, SIGNAL("canvasClicked(const
QgsPoint &, Qt::MouseButton)"), self.clickButton)
def clickButton(self, pnt, but):
currentLayer = self.iface.mapCanvas().currentLayer()
currentLayer.select(QgsRectangle(pnt.x()-0.5, pnt.y()-0.5,
pnt.x()+0.5, pnt.y()+0.5), False)
for feature in currentLayer.selectedFeatures():
system(currentLayer.actions().expandAction("open",
[("path", feature.attributeMap()[0])], 0))
Is it the right way ?
A problem is that the method doAction doesn't exist in python. Another one
is that I don't know how to call the method expandAction (types of the
arguments ?).
Any idea is welcome.
It could also be interesting to call the action with a double click.
Thank's
Karl
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Executing-Action-on-click-tp5371808p5371808.html
Sent from the qgis-developer mailing list archive at Nabble.com.
More information about the Qgis-developer
mailing list