Salome HOME
except et print
[tools/eficas.git] / InterfaceQT4 / monWidgetOptionnel.py
1 # Copyright (C) 2007-2013   EDF R&D
2 #
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License.
7 #
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 # Lesser General Public License for more details.
12 #
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Modules Python
20 # Modules Eficas
21
22 from determine import monEnvQT5
23 if monEnvQT5:
24     from PyQt5.QtWidgets import QCheckBox, QWidget
25     from PyQt5.QtCore import Qt
26 else :
27     from PyQt4.QtGui  import *
28     from PyQt4.QtCore import *
29
30 from Extensions.i18n import tr
31 from desWidgetOptionnel import Ui_WidgetOptionnel
32 from monGroupeOptionnel import MonGroupeOptionnel
33
34     
35 # Import des panels
36 class  MonWidgetOptionnel (QWidget,Ui_WidgetOptionnel):
37   def __init__(self,parentQt):
38      #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
39      QWidget.__init__(self,None)
40      self.setupUi(self)
41      self.dicoMCWidgetOptionnel={}
42      self.parentQt=parentQt
43
44   def afficheOptionnel(self,liste,MC):
45      #print "dans Optionnel ____ affiche", liste 
46      self.vireLesAutres(MC)
47      if self.dicoMCWidgetOptionnel.has_key(MC.node.item.nom) :
48         self.dicoMCWidgetOptionnel[MC.node.item.nom].setParent(None)
49         self.dicoMCWidgetOptionnel[MC.node.item.nom].close()
50      groupe = MonGroupeOptionnel(liste,self,MC)
51      self.groupesOptionnelsLayout.insertWidget(0,groupe)
52      self.dicoMCWidgetOptionnel[MC.node.item.nom]=groupe
53      return groupe
54
55   def vireLesAutres(self,MC):
56       #print "je passe dans vireLesAutres"
57       genea =MC.obj.get_genealogie()
58       #print genea
59       for k in self.dicoMCWidgetOptionnel.keys():
60           if k not in genea :  
61              self.dicoMCWidgetOptionnel[k].close()
62              del self.dicoMCWidgetOptionnel[k]
63           #if k not in genea :  print k
64       #print "________"
65       
66   def afficheOptionnelVide(self):
67       self.GeneaLabel.setText("")
68       for k in self.dicoMCWidgetOptionnel.keys():
69             self.dicoMCWidgetOptionnel[k].close()
70             del self.dicoMCWidgetOptionnel[k]
71
72   def titre(self,MC):
73      if self.parentCommande.node.editor.code in ['Adao','ADAO'] and self.parentCommande.node.editor.closeFrameRechercheCommande==True :
74         self.frameLabelCommande.close()
75         return
76      labeltext,fonte,couleur = self.parentCommande.node.item.GetLabelText()
77      l=tr(labeltext)
78      li=[]
79      while len(l) > 25:
80          li.append(l[0:24])
81          l=l[24:]
82      li.append(l)
83      texte=""
84      for l in li : texte+=l+"\n"
85      texte=texte[0:-2]
86      self.GeneaLabel.setText(tr("Options pour \n") +texte)