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 from __future__ import absolute_import
23 from builtins import str
29 from PyQt5.QtWidgets import QLineEdit
30 from PyQt5.QtCore import Qt
31 from Extensions.i18n import tr
33 from .feuille import Feuille
34 from desWidgetSimpBase import Ui_WidgetSimpBase
35 from .politiquesValidation import PolitiqueUnique
36 from .qtSaisie import SaisieValeur
39 class MonWidgetSimpBase (Ui_WidgetSimpBase,Feuille):
41 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
42 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
43 self.parentQt.commandesLayout.insertWidget(-1,self,1)
44 self.setFocusPolicy(Qt.StrongFocus)
45 self.lineEditVal.returnPressed.connect(self.LEValeurPressed)
46 self.AAfficher=self.lineEditVal
47 self.maCommande.listeAffichageWidget.append(self.lineEditVal)
48 self.lineEditVal.focusInEvent=self.monFocusInEvent
49 self.lineEditVal.focusOutEvent=self.monFocusOutEvent
52 def monFocusInEvent(self,event):
53 self.editor.nodeEnCours = self
54 QLineEdit.focusInEvent(self.lineEditVal,event)
56 def monFocusOutEvent(self,event):
57 if self.oldValeurTexte != self.lineEditVal.text():
58 self.LEValeurPressed()
59 self.oldValeurTexte= self.lineEditVal.text()
60 QLineEdit.focusOutEvent(self.lineEditVal,event)
62 #def showEvent(self, event):
63 # if self.prendLeFocus==1 :
64 # self.activateWindow()
65 # self.lineEditVal.setFocus()
67 # QWidget.showEvent(self,event)
70 #print ("dans setValeurs")
71 self.politique=PolitiqueUnique(self.node,self.editor)
72 valeur=self.node.item.get_valeur()
73 valeurTexte=self.politique.GetValeurTexte(valeur)
76 if valeurTexte != None :
77 from decimal import Decimal
78 if isinstance(valeurTexte,Decimal):
79 chaine=str(valeurTexte)
80 elif repr(valeurTexte.__class__).find("PARAMETRE") > 0:
85 # chaine=QString("").setNum(valeurTexte)
87 chaine=str(valeurTexte)
88 self.oldValeurTexte=chaine
89 self.lineEditVal.setText(chaine)
92 def finCommentaire(self):
93 mc = self.objSimp.definition
94 d_aides = { 'TXM' : tr(u"Une chaine de caracteres est attendue. "),
95 'R' : tr(u"Un reel est attendu. "),
96 'I' : tr(u"Un entier est attendu. "),
97 'Matrice' : tr(u'Une Matrice est attendue. '),
98 'Fichier' : tr(u'Un fichier est attendu. '),
99 'FichierNoAbs' : tr(u'Un fichier est attendu. '),
100 'Repertoire' : tr(u'Un repertoire est attendu. '),
101 'FichierOuRepertoire' : tr(u'Un repertoire ou un fichier est attendu. '),
102 'Heure' : tr(u'Heure sous la forme HH:MM'),
103 'Date' : tr(u'Date sous la forme JJ/MM/AA')}
104 if mc.type[0] != type:
105 commentaire = d_aides.get(mc.type[0], tr("Type de base inconnu"))
106 else : commentaire=""
110 def LEValeurPressed(self):
111 if str(self.lineEditVal.text())=="" or str(self.lineEditVal.text())==None : return
112 SaisieValeur.LEValeurPressed(self)
113 self.parentQt.donneFocus()
117 #if self.objSimp.parent.nom == "MODEL" :
118 # if self.objSimp.isvalid():
119 # self.objSimp.parent.change_fichier="1"
120 #self.node.item.parent.build_include(None,"")