Salome HOME
bug sur un mesage dans une exception sur un validator (cf JPA)
[tools/eficas.git] / InterfaceQT4 / monLayoutBouton.py
1 # Copyright (C) 2007-2021   EDF R&D
2 #
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.
7 #
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.
12 #
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
16 #
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 #
19 # Modules Python
20 # Modules Eficas
21
22 from __future__ import absolute_import
23 try :
24     from builtins import str
25 except : pass
26
27 from PyQt5.QtWidgets import  QButtonGroup, QToolButton
28 from PyQt5.QtGui import QIcon, QPixmap
29 from Extensions.i18n import tr
30
31
32 #----------------------
33 class MonLayoutBouton :
34 #----------------------
35
36 #  -------------------------------
37     def __init__(self,appliEficas):
38 #  -------------------------------
39
40         self.appliEficas = appliEficas
41         self.buttonGroup = QButtonGroup()
42
43         for etape in self.appliEficas.readercata.cata.JdC.commandes :
44             nomEtape = etape.nom
45             toolButton = QToolButton(self.appliEficas.toolBarCommande)
46             icon = QIcon()
47             if nomEtape in self.appliEficas.maConfiguration.dicoIcones:
48                 fichier = self.appliEficas.maConfiguration.dicoIcones[nomEtape]
49                 icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off)
50                 toolButton.setIcon(icon)
51             else :
52                 try :    label = nomEtape[0:3]
53                 except : label = nomEtape
54                 toolButton.setText(label)
55
56             action = self.appliEficas.toolBarCommande.addWidget(toolButton)
57             action.setVisible(True)
58             toolButton.setObjectName(nomEtape)
59             toolButton.setToolTip(tr(nomEtape))
60             self.buttonGroup.addButton(toolButton)
61
62         self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere)
63
64     def rbCliqueEtInsere(self,id):
65         self.appliEficas.handleAjoutEtape(id.objectName())