- 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
QGIS tutorials in Python
Some time ago I've started with porting Tim's tutorials posted in the blog to Python. The main reason
of doing it was to check that bindings work correctly. I thought that some people might be interested in using them so you can download them.
Download the tutorials:
- new version: >= 0.9.2 or SVN
- old version: 0.9.0 or 0.9.1
UPDATE (Jan 24, 2008): Updated with API changes which will become QGIS 0.9.2
UPDATE (May 5, 2007): Fixed tutorial 6 which was broken due API changes in vector providers.
Instructions
- unpack archive
- for every tutorial in mainwindow.py set 'qgis_path' variable to your qgis installation prefix
(needed for loading providers, projections database etc.) - set environment variables:
Linux: (when /home/wonder/qgis is used)
export LD_LIBRARY_PATH=/home/wonder/qgis/lib export PYTHONPATH=/home/wonder/qgis/share/qgis/python
Windows (when c:\qgis is used)
set PATH=c:\qgis;%PATH% set PYTHONPATH=c:\qgis\python
PYTHONPATH is there to tell python where to search for QGIS Python bindings, LD_LIBRARY_PATH (resp. PATH)
tells system where to look for QGIS libraries that Python bindings need to work. - run examples: python mainwindow.py
For running the tutorials you need QGIS from recent SVN trunk (>= r6833).
Remember that when you modify the UI or resource files, you must run 'make' to recreate files generated by pyuic4 and pyrcc4.
Copyright plugin in Python
For testing purposes I've ported also plugin for displaying copyright text from C++ to Python.
This can be helpful in case you plan to develop a Python plugin and would like to have a simple
example. It doesn't have any new functionality in comparison to original plugin. Download it here.
To run it just unpack the archive and copy the unpacked directory to python plugins dir - that's (qgis_prefix)/share/qgis/python/plugins on Linux/Mac or (qgis_prefix)/python/plugins on Windows. You might need to create 'plugins' directory if it doesn't exist yet. More information about python plugins is on wiki.
- Martin Dobias's blog
- Add new comment
- 9492 reads

Editing Tool Bars
Thank you for this valuable tutorials.
I'would Like to add a tool bar button for digitizing a polygon.
I tried to use QgsMaptoolAddRing, but unfortunately it's fail.
How could we implement this feature?
Thanks a lot
PYTHONPATH and LD_LIBRARY_PATH under mac os x
Sorry,
but under Mac OS X (with qgis from svn) I recive this error:
Traceback (most recent call last):
File "/tutorials/2_basic_main_window/mainwindow.py", line 13, in
from qgis.core import *
ImportError: No module named qgis.core
So, under Mac OS X, how I must to set LD_LIBRARY_PATH and PYTHONPATH and where I can found qgis.core and qgis.gui?
Thanks a lot
Interface Control Systems
Please let me know if I should be targeting a demonstration tutorial or a final usable plugin to handle 3d interface control of systems by piping 3d relative positions of a ball in a camera feed. Obviously this is intended to couple to the menu and data manipulation systems, but the debate is the use of python versus other options for this purpose. Someone else´s tut txt is available at http://remedials.org/BalliesScript.txt and covers quite well the background of this method of interface.
-Wilfred
WilfredGuerin@gmail.com
tutorial 2_basic_main_window
I have finally got python 2.5 bindings created for qgis and I'm keen to get started so thought I'd begin with your tutorial. However, I get this error when running mainmenu.py:
No Data Providers:
No Data Provider Plugins
/home/wonder/qgis/inst/plugins
No vector layers can be loaded. Check your QGIS installation
Can't open database: unable to open database file
Error:
Could not open SRS database /home/wonder/qgis/inst/resources/srs.dbError(14)
: unable to open database file
Have I missed something?
Path
You must set the path to your QGIS installation, open mainwindow.py and change qgix_prefix variable appropriately.
set Path under Ubuntu
Hello,
for those using Ubuntu Linux:
I found out that the tutorials work when using
qgix_prefix = "/usr"