# -*- coding: utf-8 -*-
-# Copyright (C) 2007-2013 EDF R&D
+# Copyright (C) 2007-2017 EDF R&D
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
# Modules Python
-import string,types,os,re
+from __future__ import absolute_import
+try :
+ from builtins import object
+except : pass
+
+import types,os,re
+from six.moves import range
pattern_name = re.compile(r'^[^\d\W]\w*\Z')
# Modules Eficas
-from determine import monEnvQT5
-if monEnvQT5 :
- from PyQt5.QtWidgets import QDialog
-else :
- from PyQt4.QtGui import *
- from PyQt4.QtCore import *
+from PyQt5.QtWidgets import QDialog, QMessageBox
+from PyQt5.QtCore import Qt
from Extensions.i18n import tr
from desWidgetCreeParam import Ui_desWidgetCreeParam
"""
def __init__(self,editor, name = None,fl = 0):
self.editor=editor
- self.editor.affiche_infos("")
+ self.editor.afficheInfos("")
QDialog.__init__(self,editor)
self.setupUi(self)
- if monEnvQT5 : self.connecterSignaux()
- else : self.connecterSignauxQT4()
+ self.connecterSignaux()
self.dejaExistant=0
self.listeTousParam=self.editor.jdc.params
self.dictListe={}
self.connect(self.lineEditNom,SIGNAL("returnPressed()"),self.lineEditNomReturnPressed)
def connecterSignaux(self) :
- self.lineEditVal.returnPressed(self.lineEditValReturnPressed)
- self.lineEditNom.returnPressed(self.lineEditNomReturnPressed)
-
- def CreeParametre(self):
+ self.lineEditVal.returnPressed.connect(self.lineEditValReturnPressed)
+ self.lineEditNom.returnPressed.connect(self.lineEditNomReturnPressed)
+ self.LBParam.itemDoubleClicked.connect(self.paramClicked)
+
+ def paramClicked(self,item):
+ if self.editor.nodeEnCours == None :
+ QMessageBox.warning( self, tr("Pas de Mot-Clef"),tr("Attention! selectionnez un mot-clef"))
+ return
+ param= self.dictListe[item.text()]
+ self.editor.nodeEnCours.lineEditVal.setText(param)
+ self.editor.nodeEnCours.LEvaleurPressed()
+
+
+ def creeParametre(self):
nom=str(self.lineEditNom.text())
val=str(self.lineEditVal.text())
if val == "" or None : return
else :
itemAvant=self.editor.tree.selectedItems()[0]
param=itemAvant.addParameters(True)
- param.item.set_nom(nom)
+ param.item.setNom(nom)
#PN self.val permet d entrer du texte
- param.item.set_valeur(val)
- param.update_node_texte()
- param.update_node_valid()
- self.LBParam.addItem(QString(repr(param.item)))
+ param.item.setValeur(self.val)
+ param.updateNodeTexte()
+ param.updateNodeValid()
+ self.LBParam.addItem((repr(param.item.object)))
+ self.dictListe[repr(param.item.object)] = param.item.object.nom
+ self.lineEditVal.setText("")
+ self.lineEditNom.setText("")
+ self.lineEditNom.setFocus(True)
+
def lineEditValReturnPressed(self):
valString=str(self.lineEditVal.text())
self.val=""
contexte={}
- exec "from math import *" in contexte
+ exec("from math import *", contexte)
jdc=self.editor.jdc
if jdc == None :
- self.editor.affiche_infos(tr(u"La Creation de parametre n est possible que dans un jeu de donnees"),Qt.red)
+ self.editor.afficheInfos(tr(u"La Creation de parametre n est possible que dans un jeu de donnees"),Qt.red)
return
for p in jdc.params :
try:
tp=p.nom+'='+str(repr(p.valeur))
- exec tp in contexte
+ exec(tp, contexte)
except :
pass
monTexte="monParam="+valString
try :
- exec monTexte in contexte
+ exec(monTexte, contexte)
self.val=valString
except :
try :
monTexte="monParam='"+valString+"'"
self.val="'"+valString+"'"
except :
- self.editor.affiche_infos(tr("Valeur incorrecte"),Qt.red)
- if self.lineEditNom.text()!="" and self.dejaExistant==False : self.CreeParametre()
+ self.editor.afficheInfos(tr("Valeur incorrecte"),Qt.red)
+ if self.lineEditNom.text()!="" and self.dejaExistant==False : self.creeParametre()
def lineEditNomReturnPressed(self):
if not pattern_name.match(nom) :
self.lineEditNom.setText("")
commentaire=nom + tr(" n est pas un identifiant correct\n ")
- self.editor.affiche_infos(commentaire,Qt.red)
+ self.editor.afficheInfos(commentaire,Qt.red)
for p in self.editor.jdc.params :
if p.nom==nom :
commentaire=nom + tr(" existe deja\n ")
- self.editor.affiche_infos(commentaire,Qt.red)
+ self.editor.afficheInfos(commentaire,Qt.red)
return
- if self.lineEditVal.text()!="" : self.CreeParametre()
+ if self.lineEditVal.text()!="" : self.creeParametre()
self.lineEditVal.setFocus(Qt.OtherFocusReason)
def initToutesVal(self):
self.LBParam.clear()
for param in self.listeTousParam :
- self.LBParam.addItem(QString(repr(param)))
- self.dictListe[QString(repr(param))] = param
-
+ self.LBParam.addItem((repr(param)))
+ self.dictListe[repr(param)] = param.nom
+
+
+
def valideParam(self):
if self.LBParam.selectedItems()== None : return
lParam=[]