1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013 EDF R&D
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 # Lesser General Public License for more details.
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 import string,types,os
23 from PyQt4.QtGui import *
24 from PyQt4.QtCore import *
25 from Extensions.i18n import tr
32 Classe contenant les méthodes communes aux panels
33 permettant de choisir des valeurs
39 def LEValeurPressed(self,valeur=None):
41 nouvelleValeur=str(self.lineEditVal.text())
43 if hasattr(self,"lineEditVal"):self.lineEditVal.setText(QString(valeur.nom))
45 validite,commentaire=self.politique.RecordValeur(nouvelleValeur)
46 if commentaire != "" :
47 #PNPNPNP Il faut trouver une solution pour les 2 cas
48 # self.editor.affiche_infos(commentaire)
49 #self.Commentaire.setText(QString(commentaire))
51 self.editor.affiche_infos(commentaire)
53 self.editor.affiche_infos(commentaire,Qt.red)
57 #def TraiteLEValeurTuple(self,valeurBrute=None) :
59 # if valeurBrute== None :valeurBrute=str(self.LEValeur.text())
60 # listeValeursSplit=valeurBrute.split(',')
61 # for val in listeValeursSplit :
66 # listeValeurs.append(valeur)
69 def TraiteLEValeur(self,valeurTraitee=None) :
70 # lit la chaine entree dans le line edit
71 # et la tranforme en chaine de valeurs
72 # a traiter. renvoie eventuellement des complexes
74 if valeurTraitee == None :
75 valeurBrute=str(self.LEValeur.text())
77 valeurBrute=valeurTraitee
78 if valeurBrute == str("") : return listeValeurs,1
81 valeur=eval(valeurBrute,{})
85 if type(valeur) in (types.ListType,types.TupleType) :
86 if self.node.item.wait_complex() :
88 while (indice < len(valeur)):
91 if (v== 'RI' or v == 'MP'):
93 t=tuple([v,valeur[indice+1],valeur[indice+2]])
94 listeValeurs.append(t)
97 commentaire = tr("Veuillez entrer le complexe sous forme aster ou sous forme python")
98 self.editor.affiche_infos(commentaire)
102 else : # ce n'est pas un tuple a la mode aster
103 listeValeurs.append(v)
106 else: # on n'attend pas un complexe
107 listeValeurs=valeurBrute.split(',')
109 elif type(valeur) == types.StringType:
110 listeValeurs=valeur.split(',')
112 listeValeurs.append(valeurBrute)
114 return listeValeurs,1