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
26 from PyQt4.QtGui import *
27 from PyQt4.QtCore import *
29 from Extensions.i18n import tr
30 from desWidgetOptionnel import Ui_WidgetOptionnel
35 class monButtonCustom(QCheckBox):
37 def __init__(self,texte,monOptionnel,parent=None):
38 QCheckBox.__init__(self,tr(texte),parent)
40 self.monOptionnel=monOptionnel
42 def mouseDoubleClickEvent(self, event):
43 #print "dans mouseDoubleClickEvent", self
44 if self not in self.monOptionnel.dicoCb.keys() :
47 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
48 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
49 self.setChecked(False)
53 def mousePressEvent(self, event):
54 #print "dans mousePressEvent"
55 self.mousePressed=True
56 if not( event.button() != Qt.RightButton) :
59 QCheckBox.mousePressEvent(self, event)
63 class MonWidgetOptionnel (QWidget,Ui_WidgetOptionnel):
66 def __init__(self,parentQt):
67 #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
68 QWidget.__init__(self,None)
73 self.mousePressed=False
76 self.parentQt=parentQt
77 #self.connect(self.bAjoutMC,SIGNAL("clicked()"), self.ajoutMC)
78 #print "fin init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
83 def affiche(self,liste):
84 print "dans Optionnel ____ affiche", liste
86 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
94 for l in li : texte+=l+"\n"
96 self.GeneaLabel.setText(tr("Options pour \n") +texte)
98 for cb in self.dicoCb.keys():
99 #print 'je detruis', self.dicoCb[cb], cb
106 cb = monButtonCustom(mot,self)
107 #print "j ajoute ", mot, cb
109 self.commandesOptionnellesLayout.insertWidget(0,cb)
110 self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
111 print "Fin Optionnel ____ affiche", liste
116 for cb in self.dicoCb.keys() :
117 if cb.isChecked() and self.dicoCb[cb] not in self.listeChecked : self.listeChecked.append(self.dicoCb[cb])
118 if not(cb.isChecked()) and self.dicoCb[cb] in self.listeChecked : self.listeChecked.remove(self.dicoCb[cb])
119 self.parentMC.recalculeListeMC(self.listeChecked)
124 for cb in self.dicoCb.keys():
125 if cb.isChecked() : maListe+="+"+str(cb.text())
126 if maListe=="":return
127 #print "dans Optionnel __ ajout de ", maListe
128 self.parentMC.ajoutMC(maListe)
131 self.parentQt.editor.saveSplitterSizes()