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 __future__ import absolute_import
23 from PyQt5.QtWidgets import QCheckBox, QWidget, QLabel
24 from PyQt5.QtCore import Qt
26 from Extensions.i18n import tr
27 from desGroupeOptionnel import Ui_groupeOptionnel
32 class monButtonCustom(QCheckBox):
34 def __init__(self,texte,monOptionnel,parent=None):
35 QCheckBox.__init__(self,tr(texte),parent)
36 self.mousePressed=True
38 self.monOptionnel=monOptionnel
39 self.setToolTip(tr("clicker: affichage aide, double-click: ajout"))
41 def mouseDoubleClickEvent(self, event):
42 #print "dans mouseDoubleClickEvent", self
43 if self not in self.monOptionnel.dicoCb:
46 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
47 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
51 def mousePressEvent(self, event):
52 if not( event.button() != Qt.RightButton) :
55 if self.monOptionnel.cbPressed != None :
56 self.monOptionnel.cbPressed.setChecked(False)
57 self.monOptionnel.cbPressed=self
58 if self.mousePressed == False :
59 self.mousePressed=True
61 self.mousePressed=False
63 QCheckBox.mousePressEvent(self, event)
66 def ajoutAideMC(self):
68 maDefinition = self.monOptionnel.parentMC.definition.entites[self.texte]
69 maLangue = self.monOptionnel.parentMC.jdc.lang
70 if hasattr(maDefinition,maLangue):
71 monAide = getattr(maDefinition,self.monOptionnel.parentMC.jdc.lang)
74 self.monOptionnel.parentMC.editor.affiche_commentaire(monAide)
77 class MonGroupeOptionnel (QWidget,Ui_groupeOptionnel):
80 def __init__(self,liste,parentQt,parentMC):
81 #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
82 QWidget.__init__(self,None)
86 self.mousePressed=False
89 self.parentQt=parentQt
90 self.parentMC=parentMC
92 if liste != [] : self.affiche(liste)
93 else : self.MCOptionnelLayout.insertWidget(0,QLabel(tr('Pas de MC Optionnel')))
96 def afficheTitre(self):
97 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
106 for l in li : texte+=l+"\n"
108 self.MCLabel.setText(texte)
110 def affiche(self,liste):
111 #print "dans Optionnel ____ affiche", liste
115 cb = monButtonCustom(mot,self)
116 cb.clicked.connect(cb.ajoutAideMC)
117 self.MCOptionnelLayout.insertWidget(0,cb)
119 self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
120 #print "Fin Optionnel ____ affiche", liste