[Qgis-developer] Scripting QGIS from the outside using Python
marco.hugentobler at sourcepole.ch
Mon Mar 19 03:37:05 EDT 2012
>What I have seen so far looks like you have to handle recreating the
composer and all its items using the xml like in
There has been some rearrangement in the composer classes (the first API
break :-) ). With git master version, you should be able to create a
QgsComposition by calling its readXML Method, then call
The composer is a bit of a special case because it is possible to
replace label strings, map extent / layer / rotation with parameters.
And with the legend, there is a workaround to avoid using the x-server.
So with an external python script, I'd recommend to use
On 19.03.2012 01:22, Nathan Woodrow wrote:
> It's not so much that I don't know how to create a new composer from
> Python more that I don't now how to restore a composer item from the
> project file using Python.
> I'm using the project file that contains composers as a template which
> I need to open and print. What I have seen so far looks like you have
> to handle recreating the composer and all its items using the xml like
> Maybe the composer object could do with a createFromXML() method which
> constructs a composer, and all its children, as per the project file.
> - Nathan
> On Mon, Mar 19, 2012 at 4:51 AM, Martin Dobias <wonder.sk at gmail.com
> <mailto:wonder.sk at gmail.com>> wrote:
> On Thu, Mar 15, 2012 at 2:29 PM, Nathan Woodrow
> <madmanwoo at gmail.com <mailto:madmanwoo at gmail.com>> wrote:
> > Is it possible to:
> > Load QGIS from Python (well I know how to do this using
> > QgsApplicaiton.Init())
> > Open the project file
> > Zoom to a location
> > Print the first composer to pdf
> > OR render out the map canvas to a image.
> Hi Nathan
> yes that's all possible from an external python script with PyQGIS,
> without actually starting GUI.
> > From what I can see the only way is to create a new composer
> item and pass
> > it the composer node from the xml.
> No need to play with XML, everything can be done using API, there is
> an example in the cookbook:
> Qgis-developer mailing list
> Qgis-developer at lists.osgeo.org
Dr. Marco Hugentobler
Sourcepole - Linux& Open Source Solutions
Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
marco.hugentobler at sourcepole.ch http://www.sourcepole.ch
Technical Advisor QGIS Project Steering Committee
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Qgis-developer