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 determine import monEnvQT5
25 from PyQt5.QtCore import Qt
27 from PyQt4.QtGui import *
28 from PyQt4.QtCore import *
31 from Extensions.i18n import tr
33 from feuille import Feuille
34 from politiquesValidation import PolitiqueUnique
35 from qtSaisie import SaisieValeur
38 class MonWidgetSimpTuple(Feuille):
40 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
41 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
42 self.politique=PolitiqueUnique(self.node,self.editor)
43 self.parentQt.commandesLayout.insertWidget(-1,self)
44 self.setFocusPolicy(Qt.StrongFocus)
47 valeur=self.node.item.get_valeur()
48 for i in range(self.nbValeurs) :
49 nomLineEdit="lineEditVal"+str(i+1)
50 courant=getattr(self,nomLineEdit)
51 if valeur !=None: courant.setText(str(valeur[i]))
52 setattr(self,nomLineEdit,courant)
53 if monEnvQT5: courant.returnPressed.connect(self.valeursPressed)
54 else : self.connect(courant,SIGNAL("returnPressed()"),self.valeursPressed)
56 def valeursPressed(self):
57 aLeFocus=self.focusWidget()
58 self.editor.affiche_infos("")
60 for i in range(self.nbValeurs) :
61 nomLineEdit="lineEditVal"+str(i+1)
62 courant=getattr(self,nomLineEdit)
63 if courant.text()=="" or courant.text()==None :
64 courant.setFocus(True)
67 if hasattr(self.objSimp.definition.validators, 'typeDesTuples'):
68 if self.objSimp.definition.validators.typeDesTuples[i] == "R" :
69 if (s.find('.')== -1 and s.find('e')== -1 and s.find('E')==-1) :
72 if self.objSimp.definition.validators.typeDesTuples[i] == "TXM" :
73 if s[0]!='"' and s[0] != "'":
74 if s[-1]=="'": s="'"+s
76 if s[-1]!='"' and s[-1] != "'":
80 texteValeur+=str(courant.text())
81 if i+1 != self.nbValeurs : texteValeur+=','
82 validite,commentaire=self.politique.RecordValeur(texteValeur)
83 if not validite:self.editor.affiche_infos(commentaire+" "+str(self.objSimp.definition.validators.typeDesTuples),Qt.red)
85 # Passage au champ suivant
86 nom=aLeFocus.objectName()[11:]
88 i=str(nom).toInt()[0]+1
94 if i == self.nbValeurs +1 : i=1
95 nomLineEdit="lineEditVal"+str(i)
96 courant=getattr(self,nomLineEdit)
97 courant.setFocus(True)