Salome HOME
sauve du 9 mai
[tools/eficas.git] / InterfaceQT4 / monLabelClic.py
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 # Copyright (C) 2007-2013   EDF R&D
4 #
5 # This library is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU Lesser General Public
7 # License as published by the Free Software Foundation; either
8 # version 2.1 of the License.
9 #
10 # This library is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 # Lesser General Public License for more details.
14 #
15 # You should have received a copy of the GNU Lesser General Public
16 # License along with this library; if not, write to the Free Software
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 #
19 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #
21
22 from determine import monEnvQT5
23 if monEnvQT5:
24    from PyQt5.QtWidgets import QLabel, QFrame
25    from PyQt5.QtCore import QEvent
26 else :
27    from PyQt4.QtGui import *
28    from PyQt4.QtCore import *
29 from Extensions.i18n import tr
30
31 #from Extensions.i18n import tr
32
33 class MonLabelClic(QLabel) :
34
35      def __init__(self,parent):
36         QLabel.__init__(self,parent)
37         # Pas propre mais impossible de faire fonctionner isinstance sur Groupe, MonWidgetCommande 
38         # PNPNPN ? a ameliorer
39         if isinstance (parent,QFrame): parent=parent.parent()
40         while not( hasattr(parent,'traiteClicSurLabel')) :
41              try : parent=parent.parent()
42              except : print "pb avec MonLabelClic"; break
43         self.parent=parent
44
45
46      def event(self,event) :
47          if event.type() == QEvent.MouseButtonRelease:
48             self.texte=self.text()
49             self.parent.traiteClicSurLabel(self.texte)
50          return QLabel.event(self,event)
51