From 8a1e7e6d70f69550346c719527f66af9e8f4f000 Mon Sep 17 00:00:00 2001 From: tlaveille Date: Fri, 20 Mar 2026 11:47:02 +0100 Subject: [PATCH] fix bug entre q4 et les logo/icon --- CenRa_SICEN/sicen.py | 49 ++++++++---------- CenRa_SICEN/{ => tools/icon}/sicen.png | Bin CenRa_SICEN/{ => tools/icon}/sicen_export.png | Bin CenRa_SICEN/tools/resources.py | 2 +- 4 files changed, 24 insertions(+), 27 deletions(-) rename CenRa_SICEN/{ => tools/icon}/sicen.png (100%) rename CenRa_SICEN/{ => tools/icon}/sicen_export.png (100%) diff --git a/CenRa_SICEN/sicen.py b/CenRa_SICEN/sicen.py index 02f395bd..cc70ec84 100644 --- a/CenRa_SICEN/sicen.py +++ b/CenRa_SICEN/sicen.py @@ -22,21 +22,16 @@ import csv from .forms.about_form import AboutDialog -# import psycopg2 -# import psycopg2.extras -# import base64 import socket import os -from .tools.resources import maj_verif, pyperclip +from .tools.resources import maj_verif, pyperclip, resources_path pyperclip() try: from .tools.PythonSQL import login_base except ValueError: print('Pas de fichier PythonSQL') -# import sys - class SICEN(object): @@ -73,43 +68,43 @@ class SICEN(object): self.toolBar.setObjectName("SICEN") # Create action that will start plugin configuration - self.action = QAction( - QIcon(":/plugins/sicen/sicen.png"), + self.action_open = QAction( + QIcon(resources_path("icon", "sicen.png")), u"Ouverture des données SICEN", self.iface.mainWindow()) - self.action.setEnabled(False) + self.action_open.setEnabled(False) if os.access('N:/', os.R_OK): - self.action.setEnabled(True) + self.action_open.setEnabled(True) # connect the action to the run method - self.action.triggered.connect(self.ouverture) + self.action_open.triggered.connect(self.ouverture) # Add toolbar button and menu item - self.toolBar.addAction(self.action) - self.iface.addPluginToMenu(u"SICEN", self.action) + self.toolBar.addAction(self.action_open) + self.iface.addPluginToMenu(u"SICEN", self.action_open) # Create action that will start plugin configuration - self.action = QAction( - QIcon(":/plugins/sicen/sicen_export.png"), + self.action_export = QAction( + QIcon(resources_path("icon", "sicen_export.png")), u"Export liste d'espèces", self.iface.mainWindow()) - self.action.setEnabled(False) + self.action_export.setEnabled(False) IPAddr = socket.gethostbyname(socket.gethostname()) if IPAddr[0:11] == "100.100.100": - self.action.setEnabled(True) + self.action_export.setEnabled(True) elif IPAddr[0:9] == "192.168.0": - self.action.setEnabled(True) + self.action_export.setEnabled(True) elif IPAddr[0:9] == "192.168.1": - self.action.setEnabled(True) + self.action_export.setEnabled(True) # connect the action to the run method - self.action.triggered.connect(self.export) + self.action_export.triggered.connect(self.export) # Add toolbar button and menu item - self.toolBar.addAction(self.action) - self.iface.addPluginToMenu(u"SICEN", self.action) + self.toolBar.addAction(self.action_export) + self.iface.addPluginToMenu(u"SICEN", self.action_export) self.menu = QMenu() self.menu.setTitle(QCoreApplication.translate("SICEN", "&SICEN")) - self.sicen_ouverture = QAction(QIcon(":/plugins/SICEN/sicen.png"), QCoreApplication.translate("SICEN", u"Ouverture des données SICEN"), self.iface.mainWindow()) - self.sicen_export = QAction(QIcon(":/plugins/SICEN/sicen_export.png"), QCoreApplication.translate("SICEN", u"Export liste d'espèces"), self.iface.mainWindow()) + self.sicen_ouverture = QAction(QIcon(resources_path("icon", "sicen.png")), QCoreApplication.translate("SICEN", u"Ouverture des données SICEN"), self.iface.mainWindow()) + self.sicen_export = QAction(QIcon(resources_path("icon", "sicen_export.png")), QCoreApplication.translate("SICEN", u"Export liste d'espèces"), self.iface.mainWindow()) self.menu.addActions([self.sicen_ouverture, self.sicen_export]) @@ -127,8 +122,10 @@ class SICEN(object): def unload(self): # Remove the plugin menu item and icon - self.iface.removePluginMenu(u"&SICEN", self.action) - self.iface.removeToolBarIcon(self.action) + self.iface.removePluginMenu(u"&SICEN", self.action_open) + self.iface.removeToolBarIcon(self.action_open) + self.iface.removePluginMenu(u"&SICEN", self.action_export) + self.iface.removeToolBarIcon(self.action_export) # run method that performs all the real work def ouverture(self): diff --git a/CenRa_SICEN/sicen.png b/CenRa_SICEN/tools/icon/sicen.png similarity index 100% rename from CenRa_SICEN/sicen.png rename to CenRa_SICEN/tools/icon/sicen.png diff --git a/CenRa_SICEN/sicen_export.png b/CenRa_SICEN/tools/icon/sicen_export.png similarity index 100% rename from CenRa_SICEN/sicen_export.png rename to CenRa_SICEN/tools/icon/sicen_export.png diff --git a/CenRa_SICEN/tools/resources.py b/CenRa_SICEN/tools/resources.py index 3171a987..07e4eae5 100644 --- a/CenRa_SICEN/tools/resources.py +++ b/CenRa_SICEN/tools/resources.py @@ -90,7 +90,7 @@ def resources_path(*args): :return: Absolute path to the resources folder. :rtype: str """ - path = abspath(abspath(join(plugin_path(), "CenRa_COPIE\\tools"))) + path = abspath(abspath(join(plugin_path(), "CenRa_SICEN\\tools"))) for item in args: path = abspath(join(path, item)) return path