[QGIS-Developer] Import Python modules from another installed plugin, if present

Richard Duivenvoorde rdmailings at duif.net
Wed Nov 8 10:16:04 PST 2017


On 08-11-17 18:49, Tom Chadwin wrote:
> Hello all
> 
> In a Python plugin, I would like to import some modules from another QGIS
> plugin, if it is installed. Is that possible?

Hi Tim,

Yes, I use the qgis.utils.plugins module to check if TimeManager is
available:

from qgis.utils import plugins

plugins then is a dictionary with loaded plugins

You can for example check IF a plugin is loaded:
https://github.com/rduivenvoorde/jrodos/blob/master/jrodos.py#L1463

if so you can just import modules:

from timemanager.layer_settings import LayerSettings
from timemanager.timevectorlayer import TimeVectorLayer
from timemanager.raster.wmstlayer import WMSTRasterLayer

Regards,

Richard Duivenvoorde


More information about the QGIS-Developer mailing list