From e61aff6d6540bbc57004cc8276163587a4efb51b Mon Sep 17 00:00:00 2001 From: "pascale.noyret" Date: Fri, 31 Jul 2015 11:48:04 +0200 Subject: [PATCH] Tuples avec concept --- Editeur/session.py | 2 +- Ihm/I_MCSIMP.py | 11 +++++++++- InterfaceQT4/browser.py | 21 +++++++++--------- InterfaceQT4/monWidgetPlusieursTuple.py | 29 +++++++++++++------------ InterfaceQT4/typeNode.py | 4 ++-- Noyau/N_VALIDATOR.py | 2 ++ generator/generator_python.py | 6 +++-- 7 files changed, 45 insertions(+), 30 deletions(-) diff --git a/Editeur/session.py b/Editeur/session.py index e190d288..76c420a4 100644 --- a/Editeur/session.py +++ b/Editeur/session.py @@ -283,7 +283,7 @@ def parse(args): if os.path.isfile(file): options.comm.append(file) options.studies.append({"comm":file}) - print options.studies + #print options.studies elif len(args)==1 and (re.search('.comm',file) or re.search('.map',file)): try : f=open(file,'w') diff --git a/Ihm/I_MCSIMP.py b/Ihm/I_MCSIMP.py index 1c6c87bf..e5fae814 100644 --- a/Ihm/I_MCSIMP.py +++ b/Ihm/I_MCSIMP.py @@ -109,12 +109,21 @@ class MCSIMP(I_OBJECT.OBJECT): else : txt=txt + sep + str(val) else: - txt = txt + sep+ str(val) + if isinstance(val,types.TupleType): + texteVal='(' + for i in val : + texteVal = texteVal + str(i)+',' + texteVal=texteVal[:-1]+')' + else : texteVal=str(val) + txt = txt + sep+ texteVal + if len(txt) > 200: #ligne trop longue, on tronque txt=txt+" ..." break sep=',' + # cas des listes de tuples de longueur 1 + if isinstance(val,types.TupleType) and len(self.valeur) == 1 : txt=txt+',' txt=txt+')' else: # Traitement des autres cas diff --git a/InterfaceQT4/browser.py b/InterfaceQT4/browser.py index ae530c3c..65a7e671 100644 --- a/InterfaceQT4/browser.py +++ b/InterfaceQT4/browser.py @@ -190,6 +190,7 @@ class JDCNode(QTreeWidgetItem): elif (isinstance(self.item,compoparam.PARAMTreeItem)) : name=self.appliEficas.trUtf8(str(item.GetLabelText()[0])) else: name = self.appliEficas.trUtf8(str(tr( item.nom))+" :") value = self.appliEficas.trUtf8(str( item.GetText() ) ) + mesColonnes=QStringList() if self.editor.enteteQTree=='complet': mesColonnes << name << value @@ -294,17 +295,17 @@ class JDCNode(QTreeWidgetItem): return None def affichePanneau(self) : - print "dans affichePanneau appel getPanel2", self.item.GetLabelText() + #print "dans affichePanneau appel getPanel2", self.item.GetLabelText() if self.item.isactif(): itemParent=self - print self - print self.getPanel2 + #print self + #print self.getPanel2 while not (hasattr (itemParent,'getPanel2')) : itemParent=itemParent.treeParent if itemParent!=self : itemParent.affichePanneau() return - print self.getPanel2 + #print self.getPanel2 self.fenetre=self.getPanel2() else: from monInactifPanel import PanelInactif @@ -442,11 +443,11 @@ class JDCNode(QTreeWidgetItem): indexOu=etapes.index(self.item.object) if pos=="after" : indexOu = indexOu+1 - print self.editor.Classement_Commandes_Ds_Arbre - print indexOu - print indexName - print name - print etapes + #print self.editor.Classement_Commandes_Ds_Arbre + #print indexOu + #print indexName + #print name + #print etapes for e in etapes[:indexOu] : nom=e.nom if nom not in self.editor.Classement_Commandes_Ds_Arbre : continue @@ -748,7 +749,7 @@ class JDCNode(QTreeWidgetItem): def plieToutEtReaffiche(self): - print "je suis dans plieToutEtReaffiche", self.item.get_nom() + #print "je suis dans plieToutEtReaffiche", self.item.get_nom() self.editor.deplier = False for item in self.children : item.setPlie() diff --git a/InterfaceQT4/monWidgetPlusieursTuple.py b/InterfaceQT4/monWidgetPlusieursTuple.py index 005727d3..f0a3e02f 100644 --- a/InterfaceQT4/monWidgetPlusieursTuple.py +++ b/InterfaceQT4/monWidgetPlusieursTuple.py @@ -34,7 +34,6 @@ from Tuple2 import Ui_Tuple2 from Tuple3 import Ui_Tuple3 -#class TupleCustom(QWidget,Ui_Tuple2): class TupleCustom : def __init__(self,tailleTuple,parent,parentQt,index): QWidget.__init__(self,parent) @@ -55,6 +54,7 @@ class TupleCustom : def valueChange(self): listeVal=[] + for i in range(self.tailleTuple): nomLE="lineEditVal_"+str(i+1) courant=getattr(self,nomLE) @@ -65,6 +65,10 @@ class TupleCustom : try : valeur=eval(val,{}) except : + try : + d=self.parentQt.objSimp.jdc.get_contexte_avant(self.parentQt.objSimp. etape) + valeur=eval(val,d) + except : valeur=val listeVal.append(valeur) self.valeur=listeVal @@ -81,27 +85,24 @@ class TupleCustom : if str(value[i]) != "" : valeurNulle=False except : pass - try: - courant.setText(str(value[i])) - val=str(courant.text()) + + courant.setText(str(value[i])) + val=str(courant.text()) + try : + valeur=eval(val,{}) + except : try : - valeur=eval(val,{}) + d=self.parentQt.objSimp.jdc.get_contexte_avant(self.parentQt.objSimp. etape) + valeur=eval(val,d) except : valeur=val - listeVal.append(valeur) - except : - pass + listeVal.append(valeur) if valeurNulle == True : self.valeur=None else : self.valeur=listeVal def getValeur(self): listeVal=[] - for i in range(self.tailleTuple): - nomLE="lineEditVal_"+str(i+1) - courant=getattr(self,nomLE) - val=str(courant.text()) - listeVal.append(val) - return listeVal + return self.valeur def clean(self): self.valeur=None diff --git a/InterfaceQT4/typeNode.py b/InterfaceQT4/typeNode.py index c21b19f1..aab893db 100644 --- a/InterfaceQT4/typeNode.py +++ b/InterfaceQT4/typeNode.py @@ -31,7 +31,7 @@ class PopUpMenuRacine : def createPopUpMenu(self): - print "createPopUpMenu" + #print "createPopUpMenu" self.ParamApres = QAction(tr('Parametre'),self.tree) self.tree.connect(self.ParamApres,SIGNAL("triggered()"),self.addParametersApres) self.ParamApres.setStatusTip(tr("Insere un parametre")) @@ -49,7 +49,7 @@ class PopUpMenuNodeMinimal : #---------------------------# def createPopUpMenu(self): - print "createPopUpMenu" + #print "createPopUpMenu" #self.appliEficas.salome=True self.createActions() self.menu = QMenu(self.tree) diff --git a/Noyau/N_VALIDATOR.py b/Noyau/N_VALIDATOR.py index 10b8506d..35f8bea2 100644 --- a/Noyau/N_VALIDATOR.py +++ b/Noyau/N_VALIDATOR.py @@ -1599,6 +1599,8 @@ class VerifTypeTuple(Valid, ListVal): elif type_permis == 'TXM': if type(valeur) == types.StringType: return 1 + elif isinstance(valeur, type_permis): + return 1 return 0 def verif(self, valeur): diff --git a/generator/generator_python.py b/generator/generator_python.py index 96324218..0b855e0a 100644 --- a/generator/generator_python.py +++ b/generator/generator_python.py @@ -539,8 +539,10 @@ class PythonGenerator: break if waitTuple : - s = str(obj.valeur) +',' - obj.valeurFormatee=obj.valeur + #s = str(obj.valeur) +',' + #obj.valeurFormatee=obj.valeur + s = obj.GetText() +',' + obj.valeurFormatee=obj.GetText() else : obj.valeurFormatee=[] for val in obj.valeur : -- 2.39.2