def __init__(self, iface): """Constructor. :param iface: An interface instance that will be passed to this class which provides the hook by which you can manipulate the QGIS application at run time. :type iface: QgsInterface """ # *********************************************************************** # Save reference to the QGIS interface self.iface = iface # initialize plugin directory self.plugin_dir = os.path.dirname(__file__) # initialize locale locale = QtCore.QSettings().value("locale/userLocale")[0:2] locale_path = os.path.join(self.plugin_dir, "i18n", "posttelemac_{}.qm".format(locale)) if os.path.exists(locale_path): # app=QApplication(['']) self.translator = QtCore.QTranslator() # self.translator = QTranslator(app) self.translator.load(locale_path) QtCore.QCoreApplication.installTranslator(self.translator) """ if qVersion() > '4.3.3': print 'ok' QCoreApplication.installTranslator(self.translator) #app.installTranslator(self.translator) """ # *********************************************************************** self.pluginLayerType = None self.addToRegistry() self.slf = [] # Declare instance attributes self.actions = [] self.menu = self.tr(u"&PostTelemac") # TODO: We are going to let the user set this up in a future iteration # toolbar try: from qgis.PyQt.QtGui import QToolBar except: from qgis.PyQt.QtWidgets import QToolBar toolbars = self.iface.mainWindow().findChildren(QToolBar) test = True for toolbar1 in toolbars: if toolbar1.windowTitle() == u"Telemac": self.toolbar = toolbar1 test = False break if test: self.toolbar = self.iface.addToolBar(u"Telemac") self.toolbar.setObjectName(u"Telemac") self.dlg_about = None # Processing if DOPROCESSING: self.provider = PostTelemacProvider()
def getLastDir(tool_name=''): path = '' settings = QtCore.QSettings(tool_name,"") path = settings.value("lastUsedDir",str("")) return path
import requests import site from qgis.PyQt import QtCore from qgis.core import QgsMessageLog from qgis.utils import iface # Ensure that the ext-libs for the plugin are near the front of the path # (important on Linux) dirpath = os.path.abspath(os.path.join(os.path.dirname(__file__), 'ext-libs')) sys.path, remainder = sys.path[:1], sys.path[1:] site.addsitedir(dirpath) sys.path.extend(remainder) debug = QtCore.QSettings().value('LDMP/debug', True) def log(message, level=0): if debug: QgsMessageLog.logMessage(message, tag="trends.earth", level=level) # noinspection PyPep8Naming def classFactory(iface): # pylint: disable=invalid-name """Load LDMPPlugin class from file LDMP. :param iface: A QGIS interface instance. :type iface: QgsInterface