- Release plans recap for the road to QGIS 1.0
- New version of eVis
- Contour Lines in Qgis
- QGIS and Google Summer of Code
- Quantum GIS Graduates OSGeo Incubation
- Paolo Cavallini Named to QGIS Project Steering Committee
- Nominations for QGIS PSC Open
- Capturing map coordinates in a stand alone app...
- Tutorial 7 - Creating spatial datasets with the QGIS API
- Html Image Plugin 0.2
Capturing map coordinates in a stand alone app...
Submitted by aaronr on Thu, 2008-01-24 18:51.
For those of you striving to build some stand alone Python apps based on the QGIS Python bindings here is a quick snip for ya:
class MapCoords(object):
def __init__(self, mainwindow):
self.mainwindow = mainwindow
# This one is to capture the mouse move for coordinate display
QObject.connect(mainwindow.canvas, SIGNAL("xyCoordinates(QgsPoint&)"),
self.updateCoordsDisplay)
self.latlon = QLabel("0.0 , 0.0")
self.latlon.setFixedWidth(200)
self.latlon.setAlignment(Qt.AlignHCenter)
self.latlon.setFrameStyle(QFrame.StyledPanel)
self.mainwindow.statusbar.addPermanentWidget(self.latlon)
# Signal handeler for updating coord display
def updateCoordsDisplay(self, p):
capture_string = QString(str(p.x()) + " , " +
str(p.y()))
self.latlon.setText(capture_string)
From your main app (QMainWindow object) just create one of these objects:
# New Map Coords display in status bar
self.mapcoords = MapCoords(self)
Thats all there is to it... hook up to the main canvas xyCoordinates signal and you just update a simple QLabel on the status bar of the main window.
Go forth and code...
Aaron
EMAIL: aaronr (at) z-pulley.com
WEB : http://www.reprojected.com
»
- aaronr's blog
- Add new comment
- 3784 reads

Recent comments
1 day 11 hours ago
1 day 13 hours ago
1 day 16 hours ago
1 day 17 hours ago
3 days 9 hours ago
2 weeks 1 day ago
3 weeks 1 day ago
3 weeks 1 day ago
4 weeks 5 days ago
4 weeks 6 days ago