X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FSalomeApp%2Fsalome_pluginsmanager.py;h=482d9d3ee7205ed1c67fc5809268e7b4cb8b2388;hb=7397622d22624ab84dd52c68a276e2cf50d262fb;hp=fc63c95b4dfe480c37382519e64563197c797cf8;hpb=c47605c13ccf37a7b3fcb9cb6c8baf38d3643f77;p=modules%2Fgui.git diff --git a/src/SalomeApp/salome_pluginsmanager.py b/src/SalomeApp/salome_pluginsmanager.py old mode 100755 new mode 100644 index fc63c95b4..482d9d3ee --- a/src/SalomeApp/salome_pluginsmanager.py +++ b/src/SalomeApp/salome_pluginsmanager.py @@ -1,4 +1,5 @@ -# Copyright (C) 2007-2014 CEA/DEN, EDF R&D, OPEN CASCADE +# -*- coding: utf-8 -*- +# Copyright (C) 2007-2015 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public @@ -19,12 +20,11 @@ """ This module is imported from C++ SalomeApp_Application and initialized -(call to initialize function with 4 parameters) module : 0 if it's -plugins manager at the application level 1 if it is at the module -level name : the name of the plugins manager. This name is used to -build the name of the plugins files basemenuname : the name of the -menu into we want to add the menu of the plugins ("Tools" for example) -menuname : the name of plugins menu +(call to initialize function with 4 parameters) +module : 0 if it is plugins manager at the application level, 1 if it is at the module level +name : the name of the plugins manager. This name is used to build the name of the plugins files +basemenuname : the name of the menu into we want to add the menu of the plugins ("Tools" for example) +menuname : the name of plugins menu A plugins manager is created when calling initialize. @@ -54,8 +54,7 @@ AddFunction. It is possible to customize this presentation by getting the entries list (salome_pluginsmanager.entries()) and modifying it in place. For example, you can do that : salome_pluginsmanager.entries().sort() to order them alphabetically or -salome_pluginsmanager.entries().remove("a") to remove the entry named -"a". +salome_pluginsmanager.entries().remove("a") to remove the entry named "a". It is possible to put entries in submenus. You only need to give a name with / to the entry. for example:: @@ -125,13 +124,13 @@ class Context: def find_menu(smenu): lmenus=smenu.split("|") - main=lmenus.pop(0).strip() + main=lmenus.takeFirst().trimmed() menu=sgPyQt.getPopupMenu(main) return findMenu(lmenus,menu) def findMenu(lmenu,menu): if not lmenu:return menu - m=lmenu.pop(0).strip() + m=lmenu.takeFirst().trimmed() for a in menu.actions(): if a.menu(): if a.text() == m: @@ -149,8 +148,8 @@ logger=Logger("PluginsManager") #,color=GREEN) class PluginsManager: def __init__(self,module,name,basemenuname,menuname): self.name=name - self.basemenuname=basemenuname - self.menuname=menuname + self.basemenuname=QtCore.QString.fromUtf8(basemenuname) + self.menuname=QtCore.QString.fromUtf8(menuname) self.module=module self.registry={} self.handlers={} @@ -244,7 +243,7 @@ class PluginsManager: self.menu.clear() self.menu.menuAction().setVisible(False) return - elif self.lasttime ==0: + elif self.lasttime ==0 or salome.myStudy == None: salome.salome_init(embedded=1) lasttime=0 @@ -276,8 +275,10 @@ class PluginsManager: self.entries=[] self.lasttime=lasttime for directory,plugins_file in plugins_files: + logger.debug("look for python path: %s"%directory) if directory not in sys.path: sys.path.insert(0,directory) + logger.debug("The directory %s has been added to PYTHONPATH"%directory) try: execfile(plugins_file,globals(),{}) except: