[QGIS-Developer] How to transfer data between QGIS Python plugins?

Zac Wang zacwang15 at gmail.com
Thu Apr 22 22:16:11 PDT 2021


Hi Nyall,

In my case, I maintain all the plugins myself for internal usage.

Thanks for your advice as well.


Regards,

Zac

On Fri, 23 Apr 2021 at 15:07, Nyall Dawson <nyall.dawson at gmail.com> wrote:

> On Fri, 23 Apr 2021 at 13:08, Etienne Trimaille
> <etienne.trimaille at gmail.com> wrote:
> >
> > Not recommended because others already gave the qgis.utils.plugins
> dictionary, but you can do "from plugin_a.xxxx import yyy" from you plugin
> B.
>
> Actually I would recommend avoiding both the qgis.utils.plugins
> dictionary AND the from plugin.*** approach, UNLESS you maintain both
> plugins. Plugin API isn't guaranteed to be stable, and if your plugin
> relies on someone else's plugin to work then there's the risk that
> they'll refactor and change their plugin and break yours in turn.
>
> So unless you know that this won't happen, I would strongly suggest
> going via the processing route only.
>
> Nyall
>
>
> >
> > Le ven. 23 avr. 2021 à 04:43, Tobias Schmetzer <tschmetzer at gmx.de> a
> écrit :
> >>
> >> Hello Zac,
> >>
> >> I just saw you were helped and I'm happy the functionality solved your
> problem!
> >>
> >> If you feel there's a lack of documentation and you've got an idea how
> to improve it I think the best thing to do is to support this documentation
> with a contribution. This is how I started when I realised something was
> missing and I suggested to add this or that bit of information.
> >>
> >> It's easy to sign up on GitHub and make a suggestion. You can't damage
> anything. Everything will get reviewed and maybe discussed. There's also
> guidelines in the docs how to contribute.
> >>
> >> Best regards, Tobias
> >>
> >> 22.04.2021 14:09:30 Zac Wang <zacwang15 at gmail.com>:
> >>
> >> Hi guys,
> >>
> >> Thank you for all your replies.
> >>
> >> 'qgis.utils.plugins' really resolves my problem.
> >>
> >> This issue obsessed me for a few days, and your advice is fantastic.
> >>
> >> I can't understand why there is no documentation for such a useful
> functionality.
> >>
> >> Anyway, thank you for your help. Appreciate it.
> >>
> >>
> >> Cheers,
> >>
> >> Zac
> >>
> >>
> >> On Thu, 22 Apr 2021 at 22:01, Raymond Nijssen <r.nijssen at terglobo.nl>
> wrote:
> >>>
> >>> Hi Zac,
> >>>
> >>> You can use:
> >>>
> >>> qgis.utils.plugins
> >>>
> >>> to get a dictionary with all active plugins.
> >>>
> >>>
> >>>
> >>> To find out if another plugin is available:
> >>>
> >>> 'processing' in qgis.utils.plugins
> >>>
> >>>
> >>>
> >>> And use it like:
> >>>
> >>> processing_pl = qgis.utils.plugins['processing']
> >>> processing_pl.toolbox.searchBox.setText('overlay')
> >>>
> >>>
> >>> Hope this helps,
> >>>
> >>> Raymond
> >>>
> >>>
> >>> On 22-04-2021 13:07, Zac Wang wrote:
> >>> > Hi all,
> >>> >
> >>> > Are there some ways to transfer data between different pyqgis
> plugins? I
> >>> > hope plugins share state.
> >>> >
> >>> > The only way I found is to make pluginA to be a child component of
> >>> > QgisApp(iface.mainWindow()).
> >>> >
> >>> > Then in another pluginB, call findChild() to get the object(pluginA)
> and
> >>> > connect its signal.
> >>> >
> >>> > This is a possible solution, but it's not easy to maintain because
> >>> > plugins are not initiated in the same file.
> >>> >
> >>> > Is there a better solution?
> >>> >
> >>> > Regards,
> >>> >
> >>> > Zac
> >>> >
> >>> > _______________________________________________
> >>> > QGIS-Developer mailing list
> >>> > QGIS-Developer at lists.osgeo.org
> >>> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>> >
> >>> _______________________________________________
> >>> QGIS-Developer mailing list
> >>> QGIS-Developer at lists.osgeo.org
> >>> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>
> >> _______________________________________________
> >> QGIS-Developer mailing list
> >> QGIS-Developer at lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >>
> >> _______________________________________________
> >> QGIS-Developer mailing list
> >> QGIS-Developer at lists.osgeo.org
> >> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> >
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> _______________________________________________
> QGIS-Developer mailing list
> QGIS-Developer at lists.osgeo.org
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20210423/d4d467a9/attachment.html>


More information about the QGIS-Developer mailing list