- Announcing the release of QGIS 1.5 'Tethys'
- Quantum GIS on steroids
- Annotation tools
- Announcing the release of QGIS 1.4.0 'Enceladus'
- Carson Farmer's report back on the Vienna Hackfest
- Vienna Hackfest 2009 Report Back
- Introducing the QGIS Hackfest (Vienna 2009) crew
- Announcing the release of QGIS 1.3.0 'Mimas'
- Announcing the releases of QGIS 1.0.2 (stable) and QGIS 1.1.0 'Pan' (unstable).
- Summer of Code project: Label placement
Writing a QgsMapTool in Python
Submitted by spacedman on Thu, 2007-05-03 13:58.
For my project I need to give the user three ways to define a rectangular area: it can be the bounding box of a layer, it can be the current view area, or it can be defined by the user drawing a rectangle. My main dialog covers the first two options with a dropdown and a push button, but the third option meant writing a map tool - in Python of course!
The code and details are downloadable from my site.
In short, you create a new class that inherits from QgsMapTool, set the tool on the canvas to be your tool, and then just sit back as the user interacts with the tool via the events generated. It all worked pretty well first time in Python.
So, here's hoping people will build lots of useful map tools!
Barry
»
- spacedman's blog
- Login or register to post comments
- 5660 reads

sounds very interesting -
sounds very interesting - but how to integrate in Win-binary-Version? Is there a way? Copied it to \Quantum GIS\share\qgis\python but it doesn't appear in QGIS.
Thanx
Kai
sounds very interesting -
sounds very interesting - but how to integrate in Win-binary-Version? Is there a way? Copied it to \Quantum GIS\share\qgis\python but it doesn't appear in QGIS.
Thanx
Kai
Isn't the path is something like below