[Qgis-developer] Python bindings for composer

Martin Dobias wonder.sk at gmail.com
Thu Feb 26 13:56:22 EST 2009


Hi Marco

On Thu, Feb 26, 2009 at 8:37 AM, Hugentobler  Marco
<marco.hugentobler at karto.baug.ethz.ch> wrote:
> With the bindings for composer classes it should be possible to place QActions defined in Python plugins into the composer toolbar.
> Therefore I propose the following additional function into the plugin interface (QgisInterface):
>
> QList< QPair <QMainWindow*, QgsComposerView*> > composerList()
>
> Like this, plugins can add gui elements to the main composer window and add items to the composer view. Not exposed is the class QgsComposer as that class manages the composer input widgets and I don't like to expose them to the plugin interface. It is a list because it is planned to allow several composer instances per projects in the future.

First of all I would recommend you to add signals to QgisApp that will
announce newly created (and maybe also closed) composers. Otherwise
plugins willing to add some new features to composer(s) would have to
poll for list of composers to find new ones.

Additionally, I think using a pair of composer window and composer
view for the list is a bit redundant... isn't composer view a child of
the composer window? If so, plugins could just ask for parent and cast
it to QMainWindow. Otherwise I'm affraid we would have to add a
wrapper for QList< QPair<T1*, T2*> >. Nothing really hard but better
to avoid it.


> The following additional classes would be visible from plugins:
>
> core:
> QgsComposerItem, QgsComposerLabel, QgsComposerMap, QgsComposerPicture, QgsComposerScaleBar, QgsComposition, QgsLegendModel, QgsPaperItem, QgsScaleBarStyle
>
> gui:
> QgsComposerView

Looks fine. I would have liked more if all classes were starting with
QgsComposer prefix, but I guess they're already a part of v1.0 API, so
there's not much we could do with it.

Btw. if you had some time, it would be really great if you could put
on wiki some simple examples ("recipes") for composer, e.g.:
- load a template and print the map
- put some composer items to the composition (and save as a template)
Prefferably in Python :-)

Regards
Martin


More information about the Qgis-developer mailing list