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
25 from PyQt5.QtCore import Qt
27 from PyQt4.QtGui import *
28 from PyQt4.QtCore import *
30 from Extensions.i18n import tr
31 from desWidgetOptionnel import Ui_WidgetOptionnel
36 class monButtonCustom(QCheckBox):
38 def __init__(self,texte,monOptionnel,parent=None):
39 QCheckBox.__init__(self,tr(texte),parent)
41 self.monOptionnel=monOptionnel
43 def mouseDoubleClickEvent(self, event):
44 #print "dans mouseDoubleClickEvent", self
45 if self not in self.monOptionnel.dicoCb.keys() :
48 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
49 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
50 self.setChecked(False)
54 def mousePressEvent(self, event):
55 #print "dans mousePressEvent"
56 self.mousePressed=True
57 if not( event.button() != Qt.RightButton) :
60 QCheckBox.mousePressEvent(self, event)
64 class MonWidgetOptionnel (QWidget,Ui_WidgetOptionnel):
67 def __init__(self,parentQt):
68 #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
69 QWidget.__init__(self,None)
74 self.mousePressed=False
77 self.parentQt=parentQt
78 #self.connect(self.bAjoutMC,SIGNAL("clicked()"), self.ajoutMC)
79 #print "fin init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
84 def affiche(self,liste):
85 print "dans Optionnel ____ affiche", liste
87 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
95 for l in li : texte+=l+"\n"
97 self.GeneaLabel.setText(tr("Options pour \n") +texte)
99 for cb in self.dicoCb.keys():
100 #print 'je detruis', self.dicoCb[cb], cb
107 cb = monButtonCustom(mot,self)
108 #print "j ajoute ", mot, cb
110 self.commandesOptionnellesLayout.insertWidget(0,cb)
111 self.scrollAreaCommandesOptionnelles.horizontalScrollBar().setSliderPosition(0)
112 print "Fin Optionnel ____ affiche", liste
117 for cb in self.dicoCb.keys() :
118 if cb.isChecked() and self.dicoCb[cb] not in self.listeChecked : self.listeChecked.append(self.dicoCb[cb])
119 if not(cb.isChecked()) and self.dicoCb[cb] in self.listeChecked : self.listeChecked.remove(self.dicoCb[cb])
120 self.parentMC.recalculeListeMC(self.listeChecked)
125 for cb in self.dicoCb.keys():
126 if cb.isChecked() : maListe+="+"+str(cb.text())
127 if maListe=="":return
128 #print "dans Optionnel __ ajout de ", maListe
129 self.parentMC.ajoutMC(maListe)
132 self.parentQt.editor.saveSplitterSizes()