1 # Copyright (C) 2007-2013 EDF R&D
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.
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.
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
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 from determine import monEnvQT5
24 from PyQt5.QtWidgets import QCheckBox, QWidget, QLabel
25 from PyQt5.QtCore import Qt
27 from PyQt4.QtGui import *
28 from PyQt4.QtCore import *
30 from Extensions.i18n import tr
31 from desGroupeOptionnel import Ui_groupeOptionnel
36 class monButtonCustom(QCheckBox):
38 def __init__(self,texte,monOptionnel,parent=None):
39 QCheckBox.__init__(self,tr(texte),parent)
40 self.mousePressed=True
42 self.monOptionnel=monOptionnel
43 self.setToolTip(tr("clicker: affichage aide, double-click: ajout"))
45 def mouseDoubleClickEvent(self, event):
46 #print "dans mouseDoubleClickEvent", self
47 if self not in self.monOptionnel.dicoCb.keys() :
50 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
51 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
55 def mousePressEvent(self, event):
56 if not( event.button() != Qt.RightButton) :
59 if self.monOptionnel.cbPressed != None :
60 self.monOptionnel.cbPressed.setChecked(False)
61 self.monOptionnel.cbPressed=self
62 if self.mousePressed == False :
63 self.mousePressed=True
65 self.mousePressed=False
67 QCheckBox.mousePressEvent(self, event)
70 def ajoutAideMC(self):
72 maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
73 maLangue = self.monOptionnel.parentMC.jdc.lang
74 if hasattr(maDefinition,maLangue):
75 monAide = getattr(maDefinition,self.monOptionnel.parentMC.jdc.lang)
78 self.monOptionnel.parentMC.editor.affiche_commentaire(monAide)
81 class MonGroupeOptionnel (QWidget,Ui_groupeOptionnel):
84 def __init__(self,liste,parentQt,parentMC):
85 #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
86 QWidget.__init__(self,None)
90 self.mousePressed=False
93 self.parentQt=parentQt
94 self.parentMC=parentMC
96 if liste != [] : self.affiche(liste)
97 else : self.MCOptionnelLayout.insertWidget(0,QLabel(tr('Pas de MC Optionnel')))
100 def afficheTitre(self):
101 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
109 for l in li : texte+=l+"\n"
111 self.MCLabel.setText(texte)
113 def affiche(self,liste):
114 #print "dans Optionnel ____ affiche", liste
118 cb = monButtonCustom(mot,self)
120 cb.clicked.connect(cb.ajoutAideMC)
122 self.connect(cb,SIGNAL("clicked()"), cb.ajoutAideMC)
123 self.MCOptionnelLayout.insertWidget(0,cb)
125 self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
126 #print "Fin Optionnel ____ affiche", liste