Salome HOME
modif pour MT
[tools/eficas.git] / InterfaceQT4 / monWidgetIntoSug.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017   EDF R&D
3 #
4 # This library is free software; you can redistribute it and/or
5 # modify it under the terms of the GNU Lesser General Public
6 # License as published by the Free Software Foundation; either
7 # version 2.1 of the License.
8 #
9 # This library is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 # Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public
15 # License along with this library; if not, write to the Free Software
16 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
17 #
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #
20 # Modules Python
21 from __future__ import absolute_import
22 try :
23    from builtins import str
24    from builtins import range
25 except : pass
26
27 import types,os
28
29 # Modules Eficas
30 from six.moves import range
31 from PyQt5.QtWidgets  import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
32 from PyQt5.QtWidgets  import QSizePolicy,QSpacerItem
33 from PyQt5.QtGui  import QPalette, QFont
34 from PyQt5.QtCore import Qt
35
36 from Extensions.i18n import tr
37
38 from desWidgetIntoSug        import Ui_WidgetIntoSug 
39 from monWidgetPlusieursInto  import MonWidgetPlusieursInto 
40
41 class GereAjoutDsPossible:
42   def LEValeurAjouteDsPossible(self):
43        text=str(self.lineEditVal.text())
44        if text == "" : return
45        # il faudrait essauer d en obtenir un reel, un tuple ou ...
46        # si cela est utilise pour autre chose que Telemac
47        # tout devrait etre fait ici
48        if not isinstance(text,str) : 
49           self.lineEditVal.setText("")
50           return
51        if self.node.item.hasIntoSug() : 
52           self.maListeDeValeur=list(self.node.item.getListePossibleAvecSug([]))
53           self.maListeDeValeur.insert(0,text)
54        else :
55          try :
56            self.monSimpDef.intoSug.insert(0,text)
57          except : 
58            self.monSimpDef.intoSug=list(self.monSimpDef.intoSug)
59            self.monSimpDef.intoSug.insert(0,text)
60        # selon si on est une liste ou un combo
61        try : self.ajouteValeurPossible(text)
62        except : self.setValeurs()
63
64 class MonWidgetIntoSug (Ui_WidgetIntoSug, MonWidgetPlusieursInto,GereAjoutDsPossible):
65 # Attention Attention
66 # cette wdget ne fonctionne actuellement que pour Telemac
67 # on attend du texte . on n essaye pas de transformer 
68
69   def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
70
71         MonWidgetPlusieursInto.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
72         self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)
73