我在名为SymbolManager.py
的文件中有以下类:
from qgis.core import *
class SimbolManager:
def __init__(self):
self.initSymbols()
def initSymbols(self):
self.symbolMap = {}
props = {'color': '0,0,200'}
self.symbolMap['SimpleVertex'] = QgsMarkerSymbolV2.createSimple(props)
props = {'width': '1', 'color': '0,0,255'}
self.symbolMap['SimpleLine'] = QgsLineSymbolV2.createSimple(props)
def getSymbolRenderer(self, name):
symb = self.symbolMap[name]
if symb is not None:
return QgsSingleSymbolRendererV2(symb)
return None
从同一目录中的文件我尝试以这种方式导入SymbolManager
:
from PyQt4 import QtCore, QtGui
from Ui_OsmNavigator import Ui_OsmNavigator
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
import DbConnection
from SymbolManager import SymbolManager // HERE IS THE PROBLEM
当我运行脚本时,从QGIS内部出现以下错误:
第28行,在 从SymbolManager导入SymbolManager ImportError:无法导入名称SymbolManager
我做错了什么?
答案 0 :(得分:4)
因为您的课程未被调用SymbolManager
?
class SimbolManager:
^^^^^^