Salome HOME
optim eciture
[tools/eficas.git] / InterfaceQT4 / feuille.py
index 07bd198b48cb01f012d7b2f1c2be08a7f95d80ce..717faa8e2e7a15d70229f810245d8f3f6c007705 100644 (file)
 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 #
 # Modules Python
-import string,types,os
+from __future__ import absolute_import
+try :
+  from builtins import str
+except :
+  pass
+import types,os
 import traceback
 
-from determine import monEnvQT5
-if monEnvQT5:
-   from PyQt5.QtWidgets import QToolButton ,QWidget
-   from PyQt5.QtGui import QFont, QFontMetrics
-   from PyQt5.QtCore import Qt
-else :
-   from PyQt4.QtGui import *
-   from PyQt4.QtCore import *
-from Extensions.i18n import tr
+from PyQt5.QtWidgets import QToolButton ,QWidget
+from PyQt5.QtGui import QFont, QFontMetrics
+from PyQt5.QtCore import Qt
 
+from Extensions.i18n import tr
 
-from gereIcones import ContientIcones
-from gereIcones import FacultatifOuOptionnel
-from qtSaisie    import SaisieValeur
+from .gereIcones import ContientIcones
+from .gereIcones import FacultatifOuOptionnel
+from .qtSaisie    import SaisieValeur
 
 nomMax=250
 # ---------------------------------------------------------------------- #
@@ -44,7 +44,6 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
 
    def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
        #print "Feuille", monSimpDef,nom,objSimp
-       #print self
        QWidget.__init__(self,None)
        self.node=node
        self.node.fenetre=self
@@ -79,18 +78,11 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
        self.setIconesGenerales()
        self.setCommentaire()
        self.setZoneInfo()
-          
+     
 
    def setNom(self):
        self.debutToolTip=""
-       #print "kkkkkkkkkkkkkkkkkk"
-       #print self.objSimp.nom
        nomTraduit=tr(self.objSimp.nom)
-       #print nomTraduit
-       #if len(nomTraduit) >= nomMax :
-       #  nom=nomTraduit[0:nomMax]+'...'
-       #  self.label.setText(nomTraduit)
-       #  self.debutToolTip=nomTraduit+"\n"
        longueur=QFontMetrics(self.label.font()).width(nomTraduit)
        if longueur >= nomMax :
          nouveauNom=self.formate(nomTraduit)
@@ -104,6 +96,13 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
           self.setMinimumHeight(50)
           self.resize(self.width(),200)
 
+   #def mousePressEvent(self, event):
+     #print 'mousePressEvent'
+     #import inspect
+     #print (inspect.getmro(self.__class__))
+     #self.__class__.mousePressEvent(self, event)
+
+
                                  
    def setValeurs(self):
       # print "passe dans setValeurs pour ", self.objSimp.nom
@@ -122,7 +121,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
                   'I'   : 'entiers',
                   'C'   : 'complexes'}
         type = mc.type[0]
-        if not d_aides.has_key(type) :
+        if not type in d_aides :
            if mc.min == mc.max:
                commentaire=tr("Entrez ")+str(mc.min)+tr(" valeurs ")+'\n'
            else :
@@ -134,7 +133,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
            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'
+               commentaire=tr("Entrez entre ")+"\n"+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))
@@ -151,9 +150,12 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       #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+unicode(self.objSimp.get_fr())+"</p></body></html>"
+          #c2 = '<html><head/><body><p>'+c+self.objSimp.get_fr().decode('latin-1','replace')+"</p></body></html>"
+          c2 = '<html><head/><body><p>'+c+self.objSimp.get_fr()
+          #c2 = '<html><head/><body><p>'+c+self.objSimp.get_fr()+"</p></body></html>"
           self.label.setToolTip(c2)
-          self.aide=unicode(self.objSimp.get_fr())+" "+c
+          #self.aide=self.objSimp.get_fr().decode('latin-1','ignore')+" "+c
+          self.aide=self.objSimp.get_fr()+" "+c
       else :
          c+=self.finCommentaire()
          if c != "" and c != None :
@@ -186,8 +188,11 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       if mc.min == mc.max: commentaire=tr("Entrez ")+" "+str(mc.min)+" "
       else :               commentaire=tr("Entrez entre ")+str(mc.min)+tr(" et ")+str(mc.max)
 
-      if type(mctype) == types.ClassType: ctype = getattr(mctype, 'help_message', tr("Type de base inconnu"))
-      else:                               ctype = d_aides.get(mctype, tr("Type de base inconnu"))
+      try :
+         if issubclass(mctype,object) : ctype = getattr(mctype, 'help_message', tr("Type de base inconnu"))
+         else : ctype = d_aides.get(mctype, tr("Type de base inconnu"))
+      except:                        
+         ctype = d_aides.get(mctype, tr("Type de base inconnu"))
       if ctype == tr("Type de base inconnu") and "Tuple" in str(mctype): ctype=str(mctype)
 
       commentaire+=ctype
@@ -197,11 +202,11 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
    def setZoneInfo(self):
       # info=str(self.nom)+'  '
       # if self.monSimpDef.get_fr() != None and self.monSimpDef.get_fr() != "": info+=self.monSimpDef.get_sug() +" "
-      # if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "": info+="Valeur suggérée : "self.monSimpDef.get_sug()
+      # if self.monSimpDef.get_sug() != None and self.monSimpDef.get_sug() != "": info+="Valeur suggeree : "self.monSimpDef.get_sug()
       pass
 
    def reaffiche(self):
-      #print "dans reaffiche de feuille", self.nom
+
       if self.editor.jdc.aReafficher==True :
          self.parentQt.reaffiche()
 
@@ -232,7 +237,8 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
             try :
                self.setValeursApresBouton()
             except :
-               self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
+               pass
+            self.editor.fenetreCentraleAffichee.afficheSuivant(self.AAfficher)
          else :
             if hasattr(self, 'AAfficher'): self.AAfficher.setFocus(7)
 
@@ -240,7 +246,6 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
       self.parentQt.reaffiche()
 
    def rendVisible(self):
-       #print "jjjjjjjjjjjjjjjjjjjjj"
        pass
 
    #def enterEvent(self,event):
@@ -248,8 +253,7 @@ class Feuille(QWidget,ContientIcones,SaisieValeur,FacultatifOuOptionnel):
    #   QWidget.enterEvent(self,event)
 
    def traiteClicSurLabel(self,texte):
-       #print self.aide 
-       aide=self.aide+"\n"+self.aideALaSaisie()
+       aide=self.aide.encode('latin-1', 'ignore').decode('latin-1')+"\n"+self.aideALaSaisie().encode('latin-1', 'ignore').decode('latin-1')
        self.editor.affiche_commentaire(aide)
 
    def formate(self,t):