Commit 8005ed61 authored by Benjamin Jakimow's avatar Benjamin Jakimow
Browse files - allows to call plugin without iface instance

Signed-off-by: Benjamin Jakimow's avatarBenjamin Jakimow <>
parent 1d61e0d5
......@@ -23,16 +23,17 @@
import os
import sys
import site
from qgis.PyQt.QtCore import *
from qgis.PyQt.QtGui import *
from qgis.PyQt.QtWidgets import *
import typing
from qgis.PyQt.QtCore import QCoreApplication
from qgis.PyQt.QtWidgets import QAction, QApplication
from qgis.gui import QgisInterface
class EOTimeSeriesViewerPlugin:
def __init__(self, iface):
self.iface = iface
self.mEOTSV = None
dirPlugin = os.path.dirname(__file__)
......@@ -49,8 +50,8 @@ class EOTimeSeriesViewerPlugin:
def initGui(self):
self.mToolbarActions = []
self.mToolbarActions: typing.List[QAction] = []
from qgis.utils import iface
assert isinstance(self.iface, QgisInterface)
import eotimeseriesviewer
......@@ -58,13 +59,13 @@ class EOTimeSeriesViewerPlugin:
# init main UI
from eotimeseriesviewer import DIR_UI, jp, TITLE
icon = eotimeseriesviewer.icon()
action = QAction(icon, TITLE, self.iface)
action = QAction(icon, TITLE, iface)
for action in self.mToolbarActions:
self.iface.addPluginToRasterMenu(TITLE, action)
iface.addPluginToRasterMenu(TITLE, action)
def initialDependencyCheck(self):
......@@ -87,8 +88,8 @@ class EOTimeSeriesViewerPlugin:
longText = ['Unable to import the following package(s):']
longText.append('<b>{}</b>'.format(', '.join(missing)))
longText.append('<p>Please run your local package manager(s) with root rights to install them.')
#longText.append('More information is available under:')
#longText.append('<a href=""></a> </p>')
# longText.append('More information is available under:')
# longText.append('<a href=""></a> </p>')
longText.append('This Python:')
longText.append('Executable: {}'.format(sys.executable))
......@@ -116,6 +117,7 @@ class EOTimeSeriesViewerPlugin:
EOTimeSeriesViewer._instance = None
def unload(self):
from qgis.utils import iface
from eotimeseriesviewer.main import EOTimeSeriesViewer
eotsv = EOTimeSeriesViewer.instance()
......@@ -124,9 +126,9 @@ class EOTimeSeriesViewerPlugin:
for action in self.mToolbarActions:
except Exception as ex:
print(f'Failed to unload EOTimeSeriesViewer:\n{ex}')
def tr(self, message):
return QCoreApplication.translate('EOTimeSeriesViewerPlugin', message)
\ No newline at end of file
return QCoreApplication.translate('EOTimeSeriesViewerPlugin', message)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment