Подскажите как исправить ошибку?
Код:
# Import the PyQt and QGIS libraries
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from qgis.core import *
# Initialize Qt resources from file resources_rc.py
import resources_rc
# Import required modules and if missing show the right module's name
req_mods = { "osgeo": "osgeo [python-gdal]" }
try:
from osgeo import gdal
from osgeo import ogr
except ImportError, e:
error_str = str(e)
error_mod = error_str.replace( "No module named ", "" )
if req_mods.has_key( error_mod ):
error_str = error_str.replace( error_mod, req_mods[error_mod] )
raise ImportError( error_str )
class MCCDG():
def __init__( self, iface, plugin ):
# Save reference to the QGIS interface
self.iface = iface
self.plugin = plugin
try:
self.QgisVersion = unicode( QGis.QGIS_VERSION_INT )
except:
self.QgisVersion = unicode( QGis.qgisVersion )[ 0 ]
if QGis.QGIS_VERSION[0:3] < "1.5":
# For i18n support
userPluginPath = QFileInfo( QgsApplication.qgisUserDbFilePath() ).path() + "/python/plugins/MCCDG"
systemPluginPath = QgsApplication.prefixPath() + "/python/plugins/MCCDG"
overrideLocale = QSettings().value( "locale/overrideFlag", QVariant( False ) ).toBool()
if not overrideLocale:
localeFullName = QLocale.system().name()
else:
localeFullName = QSettings().value( "locale/userLocale", QVariant( "" ) ).toString()
if QFileInfo( userPluginPath ).exists():
translationPath = userPluginPath + "/i18n/MCCDG_" + localeFullName + ".qm"
else:
translationPath = systemPluginPath + "/i18n/MCCDG_" + localeFullName + ".qm"
self.localePath = translationPath
if QFileInfo( self.localePath ).exists():
self.translator = QTranslator()
self.translator.load( self.localePath )
QCoreApplication.installTranslator( self.translator )
def initGui( self ):
if int( self.QgisVersion ) < 1:
QMessageBox.warning( self.iface.getMainWindow(), "MCCDG",
QCoreApplication.translate( "MCCDG", "Quantum GIS version detected: " ) +unicode( self.QgisVersion )+".xx\n"
+ QCoreApplication.translate( "MCCDG", "This version of MCCDG requires at least QGIS version 1.0.0\nPlugin will not be enabled." ) )
return None
from tools.MCCDG_utils import Version, GdalConfig
self.GdalVersion = Version( GdalConfig.version() )
self.menu = QMenu()
self.menu.setTitle( QCoreApplication.translate( "MCCDG", "&Calculating" ) )
if self.GdalVersion >= "1.6":
self.One = QAction( QIcon("C:/Program Files/Quantum GIS Copiapo/apps/qgis/python/plugins/MCCDG/icons/one.png"), QCoreApplication.translate( "MCCDG", "One object" ), self.iface.mainWindow() )
self.One.setStatusTip( QCoreApplication.translate( "MCCDG", "Calculation of one object") )
QObject.connect( self.One, SIGNAL( "triggered()" ), self.doOne )
self.menu.addAction(self.One)
if self.GdalVersion >= "1.6":
self.Grupp = QAction( QIcon("C:/Program Files/Quantum GIS Copiapo/apps/qgis/python/plugins/MCCDG/icons/grupp.png"), QCoreApplication.translate( "MCCDG", "Group objects" ), self.iface.mainWindow() )
self.Grupp.setStatusTip( QCoreApplication.translate( "MCCDG", "Calculation of a group of objects") )
QObject.connect( self.Grupp, SIGNAL( "triggered()" ), self.doGrupp )
self.menu.addAction(self.Grupp)
if self.GdalVersion >= "1.6":
if self.GdalVersion >= "1.6":
self.about = QAction( QIcon( "C:/Program Files/Quantum GIS Copiapo/apps/qgis/python/plugins/MCCDG/icons/prog.png" ), QCoreApplication.translate( "MCCDG", "About MCCDG" ), self.iface.mainWindow() )
self.about.setStatusTip( QCoreApplication.translate( "MCCDG", "Displays information about MCCDG" ) )
QObject.connect( self.about, SIGNAL( "triggered()" ), self.doAbout )
self.menu.addSeparator()
self.menu.addAction( self.about )
menu_bar = self.iface.mainWindow().menuBar()
actions = menu_bar.actions()
lastAction = actions[ len( actions ) - 1 ]
menu_bar.insertMenu( lastAction, self.menu )
def unload( self ):
pass
def doOne( self ):
self.d = One( self.plugin )
self.plugin.canvas.setCursor(QCursor(Qt.CrossCursor))
def doGrupp( self ):
from tools.doGrupp import MCCDGDialog as Grupp
d = Grupp( self.iface )
d.exec_()
def doAbout( self ):
from tools.doAbout import MCCDGAboutDialog as About
d = About( self.iface )
d.exec_()
class A:
def a(self):
myWidget = A()
myWidget.a(slotChangCursor)
QObject.MyWidget.setCursor(Qt.CrossCursor)
Ошибка:
Не удалось загрузить модуль MCCDG при вызове его метода classFactory()
Traceback (most recent call last):
File “C:/PROGRA~1/QUANTU~1/apps/qgis/./python\qgis\utils.py”, line 150, in startPlugin
plugins = package.classFactory(iface)
File “C:/PROGRA~1/QUANTU~1/apps/qgis/./python/plugins\MCCDG\__init__.py”, line 28, in classFactory
return MCCDG(iface)
TypeError: __init__() takes exactly 3 arguments (2 given)
Версия Python:
2.5.2 (r252:60911, Feb 21 2008, 13:11:45)
Версия QGIS:
1.5.0-Tethys Tethys, 13923M
Путь поиска Python: