Unlock Version
Lock Version
A Python module, saved into a project.qgs file, can be loaded and have specific functions run on the following project events:
openProject()saveProject()closeProject()Whether the macros are run can be configured in the application options.
If the expression engine doesn't have the function that you need. Not to worry. New functions can be added via a plugin using a simple Python API.
The new Python console gives you even more power. Now the with auto complete support, syntax highlighting, adjustable font settings. The side code editor allows for easier entry of larger blocks of code with the ability to open and run any Python file in the QGIS session.
With the expression engine being used more and more though out QGIS to allow for things like expression based labels and symbol, many more functions have been added to the expression builder and are all accessible though the expression builder. All functions include comprehensive help and usage guides for ease of use.
As this is a major release, it is not completely API compatible with previous 1.x releases. In most cases porting your code should be fairly straightforward - you can use this guide to get started. Please use the developer mailing list if you need further help.
The Python API has been revamped to allow for a more cleaner, more pythonic, programming experience. The QGIS 2.0 API uses SIP V2 which removes the messy toString(), toInt() logic that was needed when working with values. Types are now converted into native Python types making for a much nicer API. Attributes access is now done on the feature itself using a simple key lookup, no more index lookup and attribute maps.
>>> feature['mycolumn'] = 10
>>> feature['mycolumn']
10
The way features are read from a layer has also been improved allowing for multithreading in the future versions.
for feature in layer.getFeatures():
print feature['mycolumn']
Import PR from Github into Entries