Salome HOME
sauve du 9 mai
[tools/eficas.git] / InterfaceQT4 / feuille.py
index 74e4018eb99833c3277ee31d335d04d82235a717..dcd0c0683b83a1d830055a532084b1aa5a60950c 100644 (file)
 import string,types,os
 import traceback
 
-from PyQt4 import *
-from PyQt4.QtGui import *
-from PyQt4.QtCore import *
+from determine import monEnvQT5
+if monEnvQT5:
+   from PyQt5.QtWidgets import QToolButton ,QWidget
+   from PyQt5.QtGui import QFont, QFontMetrics
+else :
+   from PyQt4.QtGui import *
+   from PyQt4.QtCore import *
 from Extensions.i18n import tr
 
+
 from gereIcones import ContientIcones
 from gereIcones import FacultatifOuOptionnel
 from qtSaisie    import SaisieValeur
@@ -42,6 +47,9 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
        QWidget.__init__(self,None)
        self.node=node
        self.node.fenetre=self
+
+       # on se positionne pour les icones
+       #os.chdir(os.path.abspath(os.path.join(os.path.dirname(__file__))))
        self.setupUi(self)
        self.prendLeFocus=0
 
@@ -66,6 +74,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
        self.setIconePoubelle()
        self.setIconesFichier()
        self.setIconesSalome()
+       self.setIconesGenerales()
        self.setCommentaire()
        self.setZoneInfo()
           
@@ -79,30 +88,16 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
        #  self.debutToolTip=nomTraduit+"\n"
        longueur=QFontMetrics(self.label.font()).width(nomTraduit)
        if longueur >= nomMax :
-         print "je formate"
          nouveauNom=self.formate(nomTraduit)
-         print"________"
-         print nouveauNom
-         print"________"
-         print self
-         #self.label.setTextFormat(Qt.AutoText)
          self.label.setText(nouveauNom)
-         #self.agrandit()
        else :   
          self.label.setText(nomTraduit)
 
    def agrandit(self):
        # inutile pour certains widgets
        if self.height() < 40 :
-          print "j agrandis"
           self.setMinimumHeight(50)
-          #self.setMaximumHeight(50)
           self.resize(self.width(),200)
-          #self.principalLayout.setAlignment(Qt.AlignTop)
-          #self.label.resize(self.label.width(),200)
-          print self.label.height()
-       print self.height()
-       print "__________"
 
                                  
    def setValeurs(self):
@@ -113,6 +108,31 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
    def finCommentaire(self):
        return ""
 
+   
+   def finCommentaireListe(self):
+        commentaire=""
+        mc = self.node.item.get_definition()
+        d_aides = { 'TXM' : 'chaines de caracteres',
+                  'R'   : 'reels',
+                  'I'   : 'entiers',
+                  'C'   : 'complexes'}
+        type = mc.type[0]
+        if not d_aides.has_key(type) :
+           if mc.min == mc.max:
+               commentaire=tr("Entrez ")+str(mc.min)+tr(" valeurs ")+'\n'
+           else :
+               commentaire=tr("Entrez entre ")+str(mc.min)+tr(" et ")+str(mc.max)+tr(" valeurs ")+'\n'
+        else :
+           if mc.min == mc.max:
+               commentaire=tr("Entrez ")+str(mc.min)+" "+tr(d_aides[type])+'\n'
+           else :
+               commentaire=tr("Entrez entre ")+str(mc.min)+(" et  ")+str(mc.max) +" " +tr(d_aides[type])+'\n'
+        aideval=self.node.item.aide()
+        commentaire=commentaire +  tr(aideval)
+        self.monCommentaireLabel.setText(str(commentaire))
+        return str(commentaire)
+
+
    def setSuggestion(self):
       if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "":
          suggere=str('<html><head/><body><p><span style=" font-size:8pt;">suggestion : ')+str(self.monSimpDef.get_sug())+"</span></p></body></html>"
@@ -120,7 +140,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
 
    def setCommentaire(self):
       c  = self.debutToolTip
-      if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
+      #if self.node.item.definition.validators : c+=self.node.item.definition.validators.aide()
       self.aide=c
       if self.objSimp.get_fr() != None and self.objSimp.get_fr() != "":
           c2 = '<html><head/><body><p>'+c+str(self.objSimp.get_fr())+"</p></body></html>"
@@ -176,7 +196,6 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
    def reaffiche(self):
       #print "dans reaffiche de feuille", self.nom
       if self.editor.jdc.aReafficher==True :
-         #print " j appelle le reaffiche de parentQt"
          self.parentQt.reaffiche()
 
          #PN PN PN pas satisfaisant
@@ -187,16 +206,40 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
          #self.editor.fenetreCentraleAffichee.rendVisibleNoeud(nodeAVoir)
          #nodeAVoir.fenetre.setFocus()
          # return  # on est bien postionne
-      if self.objSimp.isvalid() and hasattr(self, 'AAfficher'):
-         self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
+
+         if self.objSimp.isvalid() and hasattr(self, 'AAfficher'):
+            nodeAVoir=self.parentQt.node.chercheNoeudCorrespondant(self.objSimp)
+            try :
+               index=self.editor.fenetreCentraleAffichee.listeAffichageWidget.index(nodeAVoir.fenetre.AAfficher)
+               if (index==len(self.editor.fenetreCentraleAffichee.listeAffichageWidget)-1) :
+                  try :
+                     nodeAVoir.fenetre.setValeursApresBouton()
+                  except :
+                     pass
+               else :
+                  self.editor.fenetreCentraleAffichee.afficheSuivant(nodeAVoir.fenetre.AAfficher)
+            except :
+               pass
       else :
-         if hasattr(self, 'AAfficher'): self.AAfficher.setFocus(7)
+         if self.objSimp.isvalid() and hasattr(self, 'AAfficher'):
+            try :
+               self.setValeursApresBouton()
+            except :
+               self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
+         else :
+            if hasattr(self, 'AAfficher'): self.AAfficher.setFocus(7)
+
+   def reaffichePourDeplier(self):
+      self.parentQt.reaffiche()
 
+   def rendVisible(self):
+       #print "jjjjjjjjjjjjjjjjjjjjj"
+       pass
 
    def traiteClicSurLabel(self,texte):
        #print self.aide 
        aide=self.aide+"\n"+self.aideALaSaisie()
-       self.editor.affiche_infos(aide)
+       self.editor.affiche_commentaire(aide)
 
    def formate(self,t):
        if t.find('_')==0 :
@@ -216,4 +259,5 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
           newText=newTexte[1:]
        return newText
       
-       
+