AW: [Qgis-developer] Python bindings for composer
Hugentobler Marco
marco.hugentobler at karto.baug.ethz.ch
Thu Feb 26 15:04:15 EST 2009
Hi Martin
Thanks for your feedback.
>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.
Agreed. I'm going to do this as soon as there is the possibility of having several composers
>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.
There are some more objects in between. The parent of QgsComposerView is mViewFrame, the parent of that mSplitter, the parent of that is centralwidget and the parent of that finally is the composer. So it would be possible to call parent()->parent()->parent()->parent() and cast that. But then someone might change the ui elements in designer and all the composer plugins would not work any more.
I already wrote a wrapper for QList< QPair<T1*, T2*> > today for the direction C++ to Python and it seems to work.
>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 :-)
Yes, this is an important point (that people unfortunately usually forget to do). Which section is the right place for this? Probably a new page under 'Help on writing plugins' ?
Regards,
Marco
-----Ursprüngliche Nachricht-----
Von: Martin Dobias [mailto:wonder.sk at gmail.com]
Gesendet: Do 26.02.2009 19:56
An: Hugentobler Marco
Cc: qgis-developer at lists.osgeo.org
Betreff: Re: [Qgis-developer] Python bindings for composer
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