[Qgis-developer] Executing Action on
click
Gavin Macaulay
gavin at macaulay.co.nz
Wed Aug 4 10:04:18 EDT 2010
Karl,
Are you aware that something similar (but not quite) already exists in Qgis? One can define actions for vector layers and and run actions for features. However, one can't do that by clicking on the feature in the map display, just in the table display.
If you are familiar with C++, perhaps you could build on the existing code rather than duplicate it with a python plugin?
Regards
Gavin
---- Original message ----
>Date: Wed, 4 Aug 2010 02:45:30 -0700 (PDT)
>From: Karl D <karl.determe at gmail.com>
>Subject: [Qgis-developer] Executing Action on click
>To: qgis-developer at lists.osgeo.org
>
>
>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.
>_______________________________________________
>Qgis-developer mailing list
>Qgis-developer at lists.osgeo.org
>http://lists.osgeo.org/mailman/listinfo/qgis-developer
More information about the Qgis-developer
mailing list