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 PyQt4.QtGui import *
23 from PyQt4.QtCore import *
24 from Extensions.i18n import tr
25 from desWidgetOptionnel import Ui_WidgetOptionnel
30 class monButtonCustom(QCheckBox):
32 def __init__(self,texte,monOptionnel,parent=None):
33 QCheckBox.__init__(self,texte,parent)
34 self.monOptionnel=monOptionnel
36 def mouseDoubleClickEvent(self, event):
37 #print "dans mouseDoubleClickEvent"
38 if self not in self.monOptionnel.dicoCb.keys() :
41 listeCheckedMC="+"+self.monOptionnel.dicoCb[self]
42 self.monOptionnel.parentMC.ajoutMC(listeCheckedMC)
43 self.setChecked(False)
47 def mousePressEvent(self, event):
48 #print "dans mousePressEvent"
49 self.mousePressed=True
50 if not( event.button() != Qt.RightButton) :
53 QCheckBox.mousePressEvent(self, event)
57 class MonWidgetOptionnel (QWidget,Ui_WidgetOptionnel):
60 def __init__(self,parentQt):
61 #print "dans init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
62 QWidget.__init__(self,None)
67 self.mousePressed=False
70 self.parentQt=parentQt
71 self.connect(self.bAjoutMC,SIGNAL("clicked()"), self.ajoutMC)
72 #print "fin init de monWidgetOptionnel ", parentQt, parentQt.node.item.nom
77 def affiche(self,liste):
78 #print "dans Optionnel ____ affiche", liste
80 labeltext,fonte,couleur = self.parentMC.node.item.GetLabelText()
88 for l in li : texte+=l+"\n"
90 self.GeneaLabel.setText(tr("Options pour \n") +texte)
92 for cb in self.dicoCb.keys():
93 #print 'je detruit', self.dicoCb[cb], cb
99 cb = monButtonCustom(QString(mot),self)
100 #print "j ajoute ", mot, cb
102 self.commandesOptionnellesLayout.insertWidget(0,cb)
103 #print "Fin Optionnel ____ affiche", liste
107 #print "kkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk"
109 for cb in self.dicoCb.keys() :
110 if cb.isChecked() and self.dicoCb[cb] not in self.listeChecked : self.listeChecked.append(self.dicoCb[cb])
111 if not(cb.isChecked()) and self.dicoCb[cb] in self.listeChecked : self.listeChecked.remove(self.dicoCb[cb])
112 self.parentMC.recalculeListeMC(self.listeChecked)
117 for cb in self.dicoCb.keys():
118 if cb.isChecked() : maListe+="+"+str(cb.text())
119 if maListe=="":return
120 #print "dans Optionnel __ ajout de ", maListe
121 self.parentMC.ajoutMC(maListe)