From ba8957e3b9ebc07dfa78a2acb93265cd07288230 Mon Sep 17 00:00:00 2001 From: Emmanuel Heriberto Oceguera Conchas <e.oceguera@gmx.de> Date: Wed, 28 Sep 2022 14:51:23 +0200 Subject: [PATCH] have benn updated --- __init__.py | 5 ++-- netCDF_visualizer.py | 41 +++++++++++++++++-------------- netCDF_visualizer_funtionality.py | 23 ++++++++--------- 3 files changed, 37 insertions(+), 32 deletions(-) diff --git a/__init__.py b/__init__.py index 1045de3..2e6bd2e 100644 --- a/__init__.py +++ b/__init__.py @@ -1,9 +1,8 @@ #the __init__ gives the construction order for the plugin - -from .netCDF_visualization import netCDF_viewer +from netCDFVisualizer.netCDF_visualizer import netCDFVisualizer def classFactory(iface): - plugin = netCDF_viewer(iface) + plugin = netCDFVisualizer(iface) return plugin diff --git a/netCDF_visualizer.py b/netCDF_visualizer.py index 0ef2f63..b6f7faf 100644 --- a/netCDF_visualizer.py +++ b/netCDF_visualizer.py @@ -33,8 +33,8 @@ from netCDF_visualizer_funtionality import * #we write a class, Plugins is a class import os -class netCDF_visualizer: - """This is a class for the netCDF_visualizer Plugin""" +class netCDFVisualizer: + """This is a class for the netCDFVisualizer Plugin""" #we set that we need the iface to build something with the class def __init__(self, iface): #our class builds netCDF_visualization Plugins @@ -44,21 +44,26 @@ class netCDF_visualizer: #when we click the plugin in QGIS the plugin will be loaded def initGui(self): - #we build the menu entry without placing it in the menu - self.pluginButton = QAction('Start', self.iface.mainWindow()) - #we add the menu entry - self.iface.addPluginToMenu('netCDF_visualizer', self.pluginButton) - #everytime the self.pluginButton is clicked the maskeAufrufen should be executed - self.pluginButton.triggered.connect(self.callMask) - + #we build the menu item without placing it already in the menu + self.pluginButton = QAction('start', self.iface.mainWindow()) + #we connect the menu item + self.iface.addPlugintoMenu('netCDFVisualizer', self.pluginButton) + #whenever self.pluginButton is clicked, the maskCall should be executed + self.iface.triggered.connect(self.callMask) + + + #when we close the plugin in QGIS the plugin will be unloaded def unload(self): - #we have to remove the self.pluginButton and the menu entry again!1 - self.iface.removePluginMenu('netCDF_visualizer', self.pluginButton) - - - def callMask (self): - #the GUI will be built! - self.unsereGui = maskAndFuntionality(self.iface) - #we open the Gui - self.unsereGui.show() + #we remove the menu item + self.iface.removePluginMenu('netCDFVisualizer', self.pluginButton) + #we remove the menu item + self.iface.removeToolBarIcon(self.pluginButton) + + #we create a function to call the mask + def callMask(self): + #we create the mask or GUI + self.mask = maskAndFuntionality(self.iface) + #we show the mask + self.mask.show() + diff --git a/netCDF_visualizer_funtionality.py b/netCDF_visualizer_funtionality.py index ff1d5a7..31641d1 100644 --- a/netCDF_visualizer_funtionality.py +++ b/netCDF_visualizer_funtionality.py @@ -24,7 +24,6 @@ #we import the impotant libraries and modules #always import the libraries and modules at the top of the code -from tkinter import Widget from PyQt5.Qtcore import * from PyQt5.QtGui import * from PyQt5.QtWidgets import * @@ -42,24 +41,26 @@ from netCDF4 import Dataset #we create the path to the ui file #Path to the Ordner where the ui file is -ncPath = os.path.dirname(__file__) #the comand dirname gives the path to the directory where the file is +ncvPath = os.path.dirname(__file__) #the comand dirname gives the path to the directory where the file is #path to the ui file -uiPath = os.path.join(ncPath, 'netCDF_visualizer.ui') +#dosn't matter where the ui file is located in the directory +uiPath = os.path.join(ncvPath, 'netCDF_visualizer.ui') -#two class +#TWO CLASES# # WIDEGT is a class for the GUI # BASE is a PyQt5 class to insatalize the GUI - WIDGET, BASE = uic.loadUiType(uiPath) -class maskAndFuntionality (WIDGET, BASE): +class maskAndFuntionality (BASE, WIDGET): + """Class for the mask and the funtionality of the netCDFVisualizer Plugin""" def __init__(self, iface): - #self = GUI/mask + #self is GUI and mask QDialog.__init__(self, iface.mainWindow()) - self.setuoUi(self) - #self is a GUI - - + self.setupUi(self) + #self ist our GUI + #the GUI is built in the running of QGIS in the current session (using the iface) + + -- GitLab