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
25 from PyQt4.QtGui import *
26 from PyQt4.QtCore import *
27 from Extensions.i18n import tr
29 from gereIcones import ContientIcones
30 from gereIcones import FacultatifOuOptionnel
31 from qtSaisie import SaisieValeur
34 # ---------------------------------------------------------------------- #
35 class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
36 # --------------------------------------------------------------------- #
39 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
40 #print "Feuille", monSimpDef,nom,objSimp
41 QWidget.__init__(self,None)
43 self.node.fenetre=self
47 maPolice= QFont("Times", 10)
48 self.setFont(maPolice)
50 self.parentQt=parentQt
51 self.editor=self.node.editor
52 self.appliEficas=self.editor.appliEficas
53 self.repIcon=self.appliEficas.repIcon
54 self.monSimpDef=monSimpDef
57 self.node.fenetre=self
58 self.maCommande=commande
60 self.aRedimensionner=0
73 nomTraduit=tr(self.objSimp.nom)
74 if len(nomTraduit) >= nomMax :
75 nom=nomTraduit[0:nomMax]+'...'
76 self.label.setText(nomTraduit)
77 self.debutToolTip=nomTraduit+"\n"
79 self.label.setText(nomTraduit)
83 # print "passe dans setValeurs pour ", self.objSimp.nom
84 # print "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
87 def finCommentaire(self):
90 def setSuggestion(self):
91 if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "":
92 suggere=str('<html><head/><body><p><span style=" font-size:8pt;">suggestion : ')+str(self.monSimpDef.get_sug())+"</span></p></body></html>"
93 if hasattr(self,'lineEditVal'): self.lineEditVal.setToolTip(suggere)
95 def setCommentaire(self):
97 if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
98 if self.objSimp.get_fr() != None and self.objSimp.get_fr() != "":
99 c2 = '<html><head/><body><p>'+c+str(self.objSimp.get_fr())+"</p></body></html>"
100 self.label.setToolTip(c2)
102 c+=self.finCommentaire()
103 if c != "" and c != None :
104 #c=str('<html><head/><body><p><span style=" font-size:8pt; ">')+c+"</span></p></body></html>"
105 c=str('<html><head/><body><p>')+c+"</p></body></html>"
106 self.label.setToolTip(c)
110 mctype = self.monSimpDef.type[0]
112 if ( hasattr(self,"BFichier")):
113 if mctype == "Repertoire":
114 self.BRepertoire=self.BFichier
115 self.connect(self.BRepertoire,SIGNAL("clicked()"),self.BRepertoirePressed)
117 #icon = QIcon(self.repIcon+"/visuFichier.png")
118 self.connect(self.BFichier,SIGNAL("clicked()"),self.BFichierPressed)
119 self.connect(self.BVisuFichier,SIGNAL("clicked()"),self.BFichierVisu)
122 if ( hasattr(self,"BSalome")):
123 enable_salome_selection = self.editor.salome and \
124 (('grma' in repr(mctype)) or ('grno' in repr(mctype)) or ('SalomeEntry' in repr(mctype)) or
125 (hasattr(mctype, "enable_salome_selection") and mctype.enable_salome_selection))
126 if enable_salome_selection:
127 self.connect(self.BSalome,SIGNAL("pressed()"),self.BSalomePressed)
129 if not(('grma' in repr(mctype)) or ('grno' in repr(mctype))) or not(self.editor.salome):
132 self.connect(self.BView2D,SIGNAL("clicked()"),self.BView2DPressed)
138 def showEvent(self, event):
139 if self.prendLeFocus==1 :
140 self.activateWindow()
141 "il faut deriver le showEvent pour" , self.nom
143 QWidget.showEvent(self,event)
145 def aideALaSaisie(self):
147 mc = self.node.item.get_definition()
149 d_aide = { 'TXM' : tr(u"chaine de caracteres"),
152 'C' : tr("complexe"),
153 'Matrice' : tr(u'Matrice'),
154 'Fichier' : tr(u'fichier'),
155 'FichierNoAbs' : tr(u'fichier existant'),
156 'Repertoire' : tr(u'repertoire')}
157 if mc.min == mc.max: commentaire=tr("Entrez ")+str(mc.min)
158 else : commentaire=tr("Entrez entre ")+str(mc.min)+tr(" et ")+str(mc.max)
160 if type(mctype) == types.ClassType: ctype = getattr(mctype, 'help_message', tr("Type de base inconnu"))
161 else: ctype = d_aides.get(mctype, tr("Type de base inconnu"))
162 if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype): ctype=str(mctype)
165 if self.max!=1 : commentaire+="s"
168 def setZoneInfo(self):
169 # info=str(self.nom)+' '
170 # if self.monSimpDef.get_fr() != None and self.monSimpDef.get_fr() != "": info+=self.monSimpDef.get_sug() +" "
171 # if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "": info+="Valeur suggérée : "self.monSimpDef.get_sug()
173 #self.editor.affiche_infos(info)