Thanks Marco, that's pretty much what I needed.<div><br></div><div>- Nathan</div><div><div><br><div class="gmail_quote">On Mon, Mar 19, 2012 at 5:37 PM, Marco Hugentobler <span dir="ltr"><<a href="mailto:marco.hugentobler@sourcepole.ch">marco.hugentobler@sourcepole.ch</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div bgcolor="#FFFFFF" text="#000000">
Hi Nathan<div class="im"><br>
<br>
>What I have seen so far looks like you have to handle recreating
the composer and all its items using the xml like in<br>
<br></div>
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
QgsComposition::readItemsFromXML.<br>
<br>
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 QgsComposition::readItemsFromXML.<br>
<br>
Regards,<br>
Marco<div><div class="h5"><br>
<br>
On 19.03.2012 01:22, Nathan Woodrow wrote:
</div></div><blockquote type="cite"><div><div class="h5">Martin,
<div><br>
</div>
<div>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.</div>
<div><br>
</div>
<div>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 in <a href="https://github.com/qgis/Quantum-GIS/blob/master/src/mapserver/qgsprojectparser.cpp" target="_blank">https://github.com/qgis/Quantum-GIS/blob/master/src/mapserver/qgsprojectparser.cpp</a></div>
<div><br>
</div>
<div>Maybe the composer object could do with a createFromXML()
method which constructs a composer, and all its children, as per
the project file.</div>
<div><br>
</div>
<div>- Nathan<br>
<br>
<div class="gmail_quote">On Mon, Mar 19, 2012 at 4:51 AM, Martin
Dobias <span dir="ltr"><<a href="mailto:wonder.sk@gmail.com" target="_blank">wonder.sk@gmail.com</a>></span>
wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>On Thu, Mar 15, 2012 at 2:29 PM, Nathan
Woodrow <<a href="mailto:madmanwoo@gmail.com" target="_blank">madmanwoo@gmail.com</a>>
wrote:<br>
> Is it possible to:<br>
><br>
> Load QGIS from Python (well I know how to do this
using<br>
> QgsApplicaiton.Init())<br>
> Open the project file<br>
> Zoom to a location<br>
> Print the first composer to pdf<br>
> OR render out the map canvas to a image.<br>
<br>
</div>
Hi Nathan<br>
<br>
yes that's all possible from an external python script with
PyQGIS,<br>
without actually starting GUI.<br>
<div><br>
> From what I can see the only way is to create a new
composer item and pass<br>
> it the composer node from the xml.<br>
<br>
</div>
No need to play with XML, everything can be done using API,
there is<br>
an example in the cookbook:<br>
<a href="http://qgis.org/pyqgis-cookbook/composer.html" target="_blank">http://qgis.org/pyqgis-cookbook/composer.html</a><br>
<span><font color="#888888"><br>
Martin<br>
</font></span></blockquote>
</div>
<br>
</div>
<br>
<fieldset></fieldset>
<br>
</div></div><div class="im"><pre>_______________________________________________
Qgis-developer mailing list
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a>
</pre>
</div></blockquote><span class="HOEnZb"><font color="#888888">
<br>
<br>
<pre cols="72">--
Dr. Marco Hugentobler
Sourcepole - Linux & Open Source Solutions
Churerstrasse 22, CH-8808 Pfäffikon SZ, Switzerland
<a href="mailto:marco.hugentobler@sourcepole.ch" target="_blank">marco.hugentobler@sourcepole.ch</a> <a href="http://www.sourcepole.ch" target="_blank">http://www.sourcepole.ch</a>
Technical Advisor QGIS Project Steering Committee</pre>
</font></span></div>
<br>_______________________________________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/mailman/listinfo/qgis-developer</a><br>
<br></blockquote></div><br></div></div>