[Qgis-user] Need Help on Coordinate Capture in Python Plugin

Aaron Racicot aaronr at z-pulley.com
Tue Jun 16 22:05:28 PDT 2009


Hi there Bruce,

Try to make the SIGNAL signature match the C++ signature as that is what
PyQt will try to match.  Specifically you are using Qt.MouseButton (the
Python version) when the C++ version would keep the '::'.

Try:

    QObject.connect(self.emitPoint, SIGNAL("canvasClicked(QgsPoint &,\
                    Qt::MouseButton)"), self.setClipWindow)

Hope that gets you going.

Aaron


--------------------------
Aaron Racicot
Z-Pulley Inc.
aaronr at z-pulley.com


-----Original Message-----
From: qgis-user-bounces at lists.osgeo.org
[mailto:qgis-user-bounces at lists.osgeo.org] On Behalf Of Bruce, Bob (CON)
Sent: Tuesday, June 16, 2009 7:06 PM
To: QGIS User List
Subject: [Qgis-user] Need Help on Coordinate Capture in Python Plugin

Hi:
	I am writing a python plugin to clip images to a user selected
rectangle and am stuck at the point where the plugin gets the
coordinates from mouse clicks. Here are some code snippets from my
plugin:

	-
	-
	-
    # connect QGSMapCanvas mouse click event to the rubber band clip
window
    # function
    self.mapCanvas = self.iface.mapCanvas()
    self.emitPoint = QgsMapToolEmitPoint(self.mapCanvas)
    self.mapCanvas.setMapTool(self.emitPoint)
    QObject.connect(self.emitPoint, SIGNAL("canvasClicked(QgsPoint &,\
                    Qt.MouseButton)"), self.setClipWindow)

    def setClipWindow(self, point, button):
        QMessageBox.information(self.iface.mainWindow(),\
           "ImageClipperDlg Mouse Click Event"," Here are the
coordinates ")


I have tried many variations of the argument lists but I cannot seem to
get the method/function setClipWindow to be called. Can someone see what
I'm doing wrong?

Thanks,
		Bob Bruce

************************************************************************
****
**  Bob Bruce, P.Eng.        Geomatics Support Engineer
**  bbruce at gov.mb.ca         Manitoba Geomatics/Remote Sensing Branch,
**  work # (204) 945-6636    1007 Century Street,
**  FAX  # (204) 945-1365    Winnipeg, Manitoba, Canada, R3H 0W4
**
**  The Manitoba Centre for:  
**     Cadastral & Topographical Mapping, and Remote Sensing
**     See us on the Web at:
http://www.gov.mb.ca/conservation/geomatics/
**  and:
http://www.gov.mb.ca/conservation/geomatics/cada_mapping/index.html
**     Check out our digital maps at: http://mlidata.gov.mb.ca/WPMLI
**        and: https://mli2.gov.mb.ca/
************************************************************************
****
_______________________________________________
Qgis-user mailing list
Qgis-user at lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/qgis-user




More information about the Qgis-user mailing list