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):
37 Feuille.__init__(self,node,monSimpDef,nom,objSimp,parentQt)
38 self.parentQt.commandesLayout.insertWidget(-1,self)
39 self.setFocusPolicy(Qt.StrongFocus)
40 self.connect(self.lineEditVal,SIGNAL("returnPressed()"),self.LEValeurPressed)
42 def showEvent(self, event):
43 if self.prendLeFocus==1 :
45 self.lineEditVal.setFocus()
47 QWidget.showEvent(self,event)
50 self.politique=PolitiqueUnique(self.node,self.editor)
51 valeur=self.node.item.get_valeur()
52 valeurTexte=self.politique.GetValeurTexte(valeur)
54 if valeurTexte != None :
55 from decimal import Decimal
56 if isinstance(valeurTexte,Decimal):
57 chaine=str(valeurTexte)
58 elif repr(valeurTexte.__class__).find("PARAMETRE") > 0:
59 chaine = QString(repr(valeur))
62 chaine=QString("").setNum(valeurTexte)
64 chaine=QString(str(valeurTexte))
65 self.lineEditVal.setText(chaine)
68 def finCommentaire(self):
69 mc = self.objSimp.definition
70 d_aides = { 'TXM' : tr(u"Une chaine de caracteres est attendue. "),
71 'R' : tr(u"Un reel est attendu. "),
72 'I' : tr(u"Un entier est attendu. "),
73 'Matrice' : tr(u'Une Matrice est attendue. '),
74 'Fichier' : tr(u'Un fichier est attendu. '),
75 'FichierNoAbs' : tr(u'Un fichier est attendu. '),
76 'Repertoire' : tr(u'Un repertoire est attendu. ')}
77 if mc.type[0] != types.ClassType:
78 commentaire = d_aides.get(mc.type[0], tr("Type de base inconnu"))
83 def LEValeurPressed(self):
84 print "LEValeurPressed"
85 print SaisieValeur.LEValeurPressed
86 SaisieValeur.LEValeurPressed(self)
87 self.parentQt.donneFocus()
89 print "je suis la aussi"
91 #if self.objSimp.parent.nom == "MODEL" :
92 # if self.objSimp.isvalid():
93 # self.objSimp.parent.change_fichier="1"
94 #self.node.item.parent.build_include(None,"")