1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 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 from __future__ import absolute_import
23 from builtins import str
24 from builtins import range
29 from PyQt5.QtCore import Qt
32 from Extensions.i18n import tr
34 from InterfaceQT4.feuille import Feuille
35 from InterfaceQT4.politiquesValidation import PolitiqueUnique
36 from InterfaceQT4.qtSaisie import SaisieValeur
39 class MonWidgetSimpTuple(Feuille):
41 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
42 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
43 self.politique=PolitiqueUnique(self.node,self.editor)
44 self.parentQt.commandesLayout.insertWidget(-1,self)
45 self.setFocusPolicy(Qt.StrongFocus)
48 valeur=self.node.item.getValeur()
49 for i in range(self.nbValeurs) :
50 nomLineEdit="lineEditVal"+str(i+1)
51 courant=getattr(self,nomLineEdit)
52 if valeur !=None: courant.setText(str(valeur[i]))
53 setattr(self,nomLineEdit,courant)
54 courant.returnPressed.connect(self.valeursPressed)
56 def valeursPressed(self):
57 aLeFocus=self.focusWidget()
58 self.editor.afficheInfos("")
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())
82 if i+1 != self.nbValeurs : texteValeur+=','
83 validite,commentaire=self.politique.recordValeur(texteValeur)
84 if not validite:self.editor.afficheInfos(commentaire+" "+str(self.objSimp.definition.validators.typeDesTuples),Qt.red)
86 # Passage au champ suivant
87 nom=aLeFocus.objectName()[11:]
95 if i == self.nbValeurs +1 : i=1
96 nomLineEdit="lineEditVal"+str(i)
97 courant=getattr(self,nomLineEdit)
98 courant.setFocus(True)