+ def ajoutScript(self):
+ # cochon mais je n arrive pas a faire mieux avec le mecanisme de plugin
+ listeCommandes=self.appliEficas.mesScripts.dict_commandes[self.tree.currentItem().item.get_nom()]
+ if type(listeCommandes) != types.TupleType: listeCommandes=(listeCommandes,)
+ numero=0
+ for commande in listeCommandes :
+ conditionSalome=commande[3]
+ if (self.appliEficas.salome == 0 and conditionSalome == True): return
+ label=commande[1]
+ tip=commande[5]
+ self.action=QAction(label,self.tree)
+ self.action.setStatusTip(tip)
+ if numero==4:
+ self.tree.connect(self.action,SIGNAL("activated()"),self.AppelleFonction4)
+ if numero==3:
+ self.tree.connect(self.action,SIGNAL("activated()"),self.AppelleFonction3)
+ numero=4
+ if numero==2:
+ self.tree.connect(self.action,SIGNAL("activated()"),self.AppelleFonction2)
+ numero=3
+ if numero==1:
+ self.tree.connect(self.action,SIGNAL("activated()"),self.AppelleFonction1)
+ numero=2
+ if numero==0:
+ self.tree.connect(self.action,SIGNAL("activated()"),self.AppelleFonction0)
+ numero=1
+ self.menu.addAction(self.action)
+
+
+ def AppelleFonction0(self):
+ self.AppelleFonction(0)
+
+ def AppelleFonction1(self):
+ self.AppelleFonction(1)
+
+ def AppelleFonction2(self):
+ self.AppelleFonction(2)
+
+ def AppelleFonction3(self):
+ self.AppelleFonction(3)
+
+ def AppelleFonction4(self):
+ self.AppelleFonction(4)
+
+
+ def AppelleFonction(self,numero):
+ listeCommandes=self.appliEficas.mesScripts.dict_commandes[self.tree.currentItem().item.get_nom()]
+ commande=listeCommandes[numero]
+ conditionValid=commande[4]
+ if (self.tree.currentItem().item.isvalid() == 0 and conditionValid == True):
+ QMessageBox.warning( None,
+ tr("item invalide"),
+ tr("l item doit etre valide"),
+ tr("&Ok"))
+ return
+ fonction=commande[0]
+ listenomparam=commande[2]
+ listeparam=[]
+ for p in listenomparam:
+ if hasattr(self.tree.currentItem(),p):
+ listeparam.append(getattr(self.tree.currentItem(),p))
+ if p=="self" : listeparam.append(self)
+ try :
+ fonction(listeparam,self.appliEficas)
+ except :
+ fonction(listeparam)
+
+