[Qgis-developer] Python bindings for composer

Martin Dobias wonder.sk at gmail.com
Thu Feb 26 15:36:41 EST 2009


On Thu, Feb 26, 2009 at 9:04 PM, Hugentobler  Marco
<marco.hugentobler at karto.baug.ethz.ch> wrote:
>>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.

Alternatively you could add a method to QgsComposerView that would
return pointer to its main window to avoid the need of QPair.
And maybe I would change the name of the function for qgis interface
from composerList() to activeComposers() but that's just a matter of
taste :)


>>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' ?

It think the best would be to add a completely new page, something
like Coding Recipes or Developer's Cookbook that would list the
examples, each topic (geometries, vectors, rasters, rendering,
composer, ...) on a separate subpage. Then I would also like to
migrate much of the contents from PythonBindings page there
(PythonBindings has been originally created to record status and
compilation of pyQGIS, however now it contains mostly useful code
snippets).

Martin


More information about the Qgis-developer mailing list