Questions tagged «nameerror»

1
从QGIS Python插件添加PostGIS层
我尝试开发一个插件,以从插件中向qgis添加postgis层,作为学习python的一部分。 如果我从qgis中的python控制台运行它,则用于添加postgis图层的代码可以从食谱中获取,并且可以正常工作(如果在对话框result == 1中按了OK按钮,则应该将我的图层添加到qgis中)。 但是,如果我从插件运行它,则会引发消息NameError:未定义名称'QgsDataSourceURI'。为什么从插件运行该错误? 我如何从插件/函数内部添加图层与从Python控制台添加图层有区别吗? def run(self): """Run method that performs all the real work""" # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() # See if OK was pressed if result == 1: # Do something useful here - delete the line containing …
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.