简体   繁体   English

如何从python脚本运行QGIS插件

[英]How to run QGIS plugin from python script

I would like to access external qgis plugins through a python script. 我想通过python脚本访问外部qgis插件。 I have been able to access the built in qgis processing and vector toolboxs, but have been unsuccessful with external plugins such as the topology checker plugin. 我已经能够访问内置的qgis处理和矢量工具箱,但是对于外部插件(例如拓扑检查器插件)却没有成功。 I have tried this both using the built in qgis python console, and an exteranl IDE, but attempts have failed. 我已经使用内置的qgis python控制台和exteranl IDE进行了尝试,但是尝试均失败了。

I am sure that there is a way to do this, has someone done this before? 我确信有办法做到这一点,以前有人做过吗?

Thank you! 谢谢!

You could add the qgis plugin folder to your path. 您可以将qgis插件文件夹添加到您的路径。 That way you should be able to import them as a module. 这样,您应该能够将它们作为模块导入。

Have a look at my blog to find a way to load QGIS plugins in a standalone PyQGIS application (in Spanish): 看看我的博客,以找到在独立的PyQGIS应用程序(西班牙语)中加载QGIS插件的方法:

http://geotux.tuxfamily.org/index.php/en/component/k2/item/229-cargando-plugins-de-quantum-gis-en-el-visor-de-pyqgis http://geotux.tuxfamily.org/index.php/en/component/k2/item/229-cargando-plugins-de-quantum-gis-en-el-visor-de-pyqgis

在此处输入图片说明

There you'll find a QgisInterface class, which you must use to be able to run plugins out of QGIS. 在这里,您将找到QgisInterface类,必须使用该类才能在QGIS之外运行插件。 This class is now being employed by QGIS devs to run PyQGIS tests. QGIS开发人员现在正在使用该类来运行PyQGIS测试。

As you can se, the blog post is very old, so I don't warrant it'll work out of the box, but for sure it's a very good guide for you to accomplish what you want. 如您所知,该博客文章非常古老,因此我不保证它会立即可用,但是可以肯定的是,它对于您完成所需的工作非常有用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM