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
24 from PyQt4.QtGui import *
25 from PyQt4.QtCore import *
26 from Extensions.i18n import tr
28 from feuille import Feuille
29 from desWidgetSimpBase import Ui_WidgetSimpBase
30 from politiquesValidation import PolitiqueUnique
31 from qtSaisie import SaisieValeur
34 class MonWidgetSimpBase (Ui_WidgetSimpBase,Feuille):
36 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
37 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
38 #print "MonWidgetSimpBase", nom
39 self.parentQt.commandesLayout.insertWidget(-1,self,1)
40 self.setFocusPolicy(Qt.StrongFocus)
41 self.connect(self.lineEditVal,SIGNAL("returnPressed()"),self.LEValeurPressed)
42 self.AAfficher=self.lineEditVal
43 self.maCommande.listeAffichageWidget.append(self.lineEditVal)
46 #def showEvent(self, event):
47 # if self.prendLeFocus==1 :
48 # self.activateWindow()
49 # self.lineEditVal.setFocus()
51 # QWidget.showEvent(self,event)
54 self.politique=PolitiqueUnique(self.node,self.editor)
55 valeur=self.node.item.get_valeur()
56 valeurTexte=self.politique.GetValeurTexte(valeur)
59 if valeurTexte != None :
60 from decimal import Decimal
61 if isinstance(valeurTexte,Decimal):
62 chaine=str(valeurTexte)
63 elif repr(valeurTexte.__class__).find("PARAMETRE") > 0:
64 chaine = QString(repr(valeur))
68 # chaine=QString("").setNum(valeurTexte)
70 chaine=QString(str(valeurTexte))
71 self.lineEditVal.setText(chaine)
74 def finCommentaire(self):
75 mc = self.objSimp.definition
76 d_aides = { 'TXM' : tr(u"Une chaine de caracteres est attendue. "),
77 'R' : tr(u"Un reel est attendu. "),
78 'I' : tr(u"Un entier est attendu. "),
79 'Matrice' : tr(u'Une Matrice est attendue. '),
80 'Fichier' : tr(u'Un fichier est attendu. '),
81 'FichierNoAbs' : tr(u'Un fichier est attendu. '),
82 'Repertoire' : tr(u'Un repertoire est attendu. '),
83 'Heure' : tr(u'Heure sous la forme HH:MM'),
84 'Date' : tr(u'Date sous la forme JJ/MM/AA')}
85 if mc.type[0] != types.ClassType:
86 commentaire = d_aides.get(mc.type[0], tr("Type de base inconnu"))
91 def LEValeurPressed(self):
92 if str(self.lineEditVal.text())=="" or str(self.lineEditVal.text())==None : return
93 SaisieValeur.LEValeurPressed(self)
94 self.parentQt.donneFocus()
98 #if self.objSimp.parent.nom == "MODEL" :
99 # if self.objSimp.isvalid():
100 # self.objSimp.parent.change_fichier="1"
101 #self.node.item.parent.build_include(None,"")