class AprImport: def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # Create the dialog and keep reference self.dlg = AprImportDialog(self.iface) # initialize plugin directory self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/aprimport" # initialize locale localePath = "" locale = QSettings().value("locale/userLocale").toString()[0:2] if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/aprimport_" + locale + ".qm" if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator) def initGui(self): # Create action that will start plugin configuration self.action = QAction(QIcon(":/plugins/aprimport/icons/icon.jpg"), \ u"ArcView-APR-Import", self.iface.mainWindow()) # connect the action to the run method QObject.connect(self.action, SIGNAL("triggered()"), self.run) # Add toolbar button and menu item self.iface.addToolBarIcon(self.action) self.iface.addPluginToMenu(u"&ArcView-APR-Import", self.action) def unload(self): # Remove the plugin menu item and icon self.iface.removePluginMenu(u"&ArcView-APR-Import",self.action) self.iface.removeToolBarIcon(self.action) # run method that performs all the real work def run(self): # show the dialog self.dlg.show()
def __init__(self, iface): # Save reference to the QGIS interface self.iface = iface # Create the dialog and keep reference self.dlg = AprImportDialog(self.iface) # initialize plugin directory self.plugin_dir = QFileInfo(QgsApplication.qgisUserDbFilePath()).path() + "/python/plugins/aprimport" # initialize locale localePath = "" locale = QSettings().value("locale/userLocale").toString()[0:2] if QFileInfo(self.plugin_dir).exists(): localePath = self.plugin_dir + "/i18n/aprimport_" + locale + ".qm" if QFileInfo(localePath).exists(): self.translator = QTranslator() self.translator.load(localePath) if qVersion() > '4.3.3': QCoreApplication.installTranslator(self.translator)