Hi Larry,

Am 28.02.2013 17:38, schrieb Larry Shaffer:
Hi,

On Thu, Feb 28, 2013 at 12:01 AM, Bernhard Ströbl
<[email protected] <mailto:[email protected]>> wrote:

    Hi Kelly,

    I am doing something similar for my company but I am developing it
    for the next release, because master has
    QgsComposition::__loadFromTemplate method, which 1.8 has not.

    However to get a new printComposer you can use
    self.iface.__actionPrintComposer().trigger(__)
    which adds a new composer to the project's list of composers.


In master branch, and in the last week, the actionPrintComposer() (i.e.
QgisApp::createNewComposer) 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.

hmm, my master dates from Febr. 21, have to update...
Is this a needed feature? I mean any text processing software creates "document1" or "unknown1" if you hit the new document button

There are a couple of possible solutions:

* Expose Qgis::createNewComposer 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.

+1
the actionPrintComposer().trigger() thing is not so straightforward

* 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.

* Use a different action in the GUI than actionPrintComposer(). Might
lead to some confusion, having semi-redundant actions. New PyQGIS code
remains identical to 1.8.


    But AFAIK you can not load a template into it with 1.8


I think this is possible. QgsComposition has readXML and addItemsFromXML
exposed in 1.8 [0]. If you look at loadFromTemplate[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 neccessarily, I sometimes happen to work on a composer (created from template) but I somehow screw things up and then it is nice to restart again without leaving the composer. This is the behavior of QGIS, so IMHO it is ok if loadFromTemplate behaves in the same manner.

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.

I did not fiddle with those 1.8 methods, but thinking about it it should even be possible to do substitution using PyQt methods, i.e.
1) read file
2) do substitutions
3) create the XMLDoc
4) load into composer

I will check and report back

Bernhard

[0] http://qgis.org/api/1.8/classQgsComposition.html
[1]
https://github.com/qgis/Quantum-GIS/blob/master/src/core/composer/qgscomposition.cpp#L382


Regards,

Larry

    Bernhard

    Am 28.02.2013 03:38, schrieb Kelly Thomas:

        Hello,


        I am building a python plugin for QGIS 1.8 and am trying to
        manipulate the map composers.

        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.

        I know that current composers can be listed by calling
        qgis.utils.iface.__activeComposers().

        However I have been unable to create or destroy composer windows
        without resorting to spoofing user input to the composer manager
        dialog!

        Is there a technique by which I can add/remove composers
        programmatically?

        Thanks,
        Kelly Thomas
        _________________________________________________
        Qgis-developer mailing list
        [email protected]
        <mailto:[email protected]>
        http://lists.osgeo.org/__mailman/listinfo/qgis-__developer
        <http://lists.osgeo.org/mailman/listinfo/qgis-developer>


        __________ Information from ESET Mail Security, version of virus
        signature database 8058 (20130227) __________

        The message was checked by ESET Mail Security.
        http://www.eset.com




    __________ Information from ESET Mail Security, version of virus
    signature database 8058 (20130227) __________

    The message was checked by ESET Mail Security.
    http://www.eset.com


    _________________________________________________
    Qgis-developer mailing list
    [email protected] <mailto:[email protected]>
    http://lists.osgeo.org/__mailman/listinfo/qgis-__developer
    <http://lists.osgeo.org/mailman/listinfo/qgis-developer>





__________ Information from ESET Mail Security, version of virus signature 
database 8061 (20130228) __________

The message was checked by ESET Mail Security.
http://www.eset.com


_______________________________________________
Qgis-developer mailing list
[email protected]
http://lists.osgeo.org/mailman/listinfo/qgis-developer

Reply via email to