<div dir="ltr">Hi,<br><div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 28, 2013 at 12:01 AM, Bernhard Ströbl <span dir="ltr"><<a href="mailto:bernhard.stroebl@jena.de" target="_blank">bernhard.stroebl@jena.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Kelly,<br>
<br>
I am doing something similar for my company but I am developing it for the next release, because master has QgsComposition::<u></u>loadFromTemplate method, which 1.8 has not.<br>
<br>
However to get a new printComposer you can use<br>
self.iface.<u></u>actionPrintComposer().trigger(<u></u>)<br>
which adds a new composer to the project's list of composers. </blockquote><div><br><div>In master branch, and in the last week, the actionPrintComposer() (i.e. 
<span style="color:rgb(0,0,0)">QgisApp::</span><span style="color:rgb(0,0,0)">createNewComposer</span>)
 action will now present the user with a dialog to help choose a unique 
composer title, before the composer is created. Since 
iface.actionPrintComposer().trigger() still appears to be the best means
 of programmatically creating a new composer, this presents an issue.<br><br></div>There are a couple of possible solutions:<br><br><span style="color:rgb(0,0,0)">* Expose </span><span style="color:rgb(0,0,0)"></span><span style="color:rgb(0,0,0)">Qgis::createNewComposer</span>
 in iface (which returns pointer to new composer). Maybe adding 
duplicateComposer, deleteComposer and deletePrintComposers, as well. 
Makes the most sense to me. New PyQGIS code would be different from 1.8.<br><br>*
 Add a preference in Options for turning it on/off (e.g. [x] Prompt for
 composer name), and maybe simple get/set methods to QgisApp and iface. 
New PyQGIS code would require a couple of lines of additional code if the prompt was not to 
be shown.<br><br>* Use a different action in the GUI than actionPrintComposer()<span style="color:rgb(0,0,0)">. Might lead to some confusion, having semi-redundant actions. </span><span style="color:rgb(0,0,0)">New PyQGIS code remains identical to 1.8.</span><br>
 <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">But AFAIK you can not load a template into it with 1.8<br></blockquote><div><br></div>
<div>I think this is possible. QgsComposition has readXML and addItemsFromXML exposed in 1.8 [0]. If you look at <span class="">loadFromTemplate</span><span class=""></span> [1], the initial routines are for clearing a composition's existing items (btw: I think that is bad. IMO loading from a template should always be in a fresh composer). Not a concern if you are starting with a fresh composer anyway. After that, there is substitution replacement (not sure if relevant to 1.8), reading of the XML doc, then adding the items, all of which should be doable in Python, unless I am mistaken.<br>
<br>[0] <a href="http://qgis.org/api/1.8/classQgsComposition.html">http://qgis.org/api/1.8/classQgsComposition.html</a><br></div><div>[1] <a href="https://github.com/qgis/Quantum-GIS/blob/master/src/core/composer/qgscomposition.cpp#L382">https://github.com/qgis/Quantum-GIS/blob/master/src/core/composer/qgscomposition.cpp#L382</a> <br>
<br></div><div>Regards,<br><br></div><div>Larry<br></div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Bernhard<br>
<br>
Am 28.02.2013 03:38, schrieb Kelly Thomas:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Hello,<br>
<br>
<br>
I am building a python plugin for QGIS 1.8 and am trying to manipulate the map composers.<br>
<br>
The goal is to load a template, customise a few elements, and then leave the composer window up for the user to modify / print / etc.<br>
<br>
I know that current composers can be listed by calling qgis.utils.iface.<u></u>activeComposers().<br>
<br>
However I have been unable to create or destroy composer windows without resorting to spoofing user input to the composer manager dialog!<br>
<br>
Is there a technique by which I can add/remove composers programmatically?<br>
<br>
Thanks,<br>
Kelly Thomas                                    <br>
______________________________<u></u>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a><br>
<br>
<br>
__________ Information from ESET Mail Security, version of virus signature database 8058 (20130227) __________<br>
<br>
The message was checked by ESET Mail Security.<br>
<a href="http://www.eset.com" target="_blank">http://www.eset.com</a><br>
<br>
<br>
</blockquote>
<br>
<br>
__________ Information from ESET Mail Security, version of virus signature database 8058 (20130227) __________<br>
<br>
The message was checked by ESET Mail Security.<br>
<a href="http://www.eset.com" target="_blank">http://www.eset.com</a><br>
<br>
<br>
______________________________<u></u>_________________<br>
Qgis-developer mailing list<br>
<a href="mailto:Qgis-developer@lists.osgeo.org" target="_blank">Qgis-developer@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/qgis-developer" target="_blank">http://lists.osgeo.org/<u></u>mailman/listinfo/qgis-<u></u>developer</a><br>
</blockquote></div><br></div></div></div>