1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2021 EDF R&D
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.
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.
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
18 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from __future__ import absolute_import
23 from builtins import str
24 from builtins import range
30 from PyQt5.QtWidgets import QCheckBox, QScrollBar, QFrame, QApplication, QLabel
31 from PyQt5.QtWidgets import QSizePolicy,QSpacerItem
32 from PyQt5.QtGui import QPalette, QFont
33 from PyQt5.QtCore import Qt
35 from Extensions.i18n import tr
37 from desWidgetIntoSug import Ui_WidgetIntoSug
38 from monWidgetPlusieursInto import MonWidgetPlusieursInto
40 class GereAjoutDsPossible:
41 def LEValeurAjouteDsPossible(self):
42 text=str(self.lineEditVal.text())
43 if text == "" : return
44 # il faudrait essauer d en obtenir un reel, un tuple ou ...
45 # si cela est utilise pour autre chose que Telemac
46 # tout devrait etre fait ici
47 if not isinstance(text,str) :
48 self.lineEditVal.setText("")
50 if self.node.item.hasIntoSug() :
51 self.maListeDeValeur=list(self.node.item.getListePossibleAvecSug([]))
52 self.maListeDeValeur.insert(0,text)
55 self.monSimpDef.intoSug.insert(0,text)
57 self.monSimpDef.intoSug=list(self.monSimpDef.intoSug)
58 self.monSimpDef.intoSug.insert(0,text)
59 # selon si on est une liste ou un combo
60 try : self.ajouteValeurPossible(text)
61 except : self.setValeurs()
63 class MonWidgetIntoSug (Ui_WidgetIntoSug, MonWidgetPlusieursInto,GereAjoutDsPossible):
65 # cette wdget ne fonctionne actuellement que pour Telemac
66 # on attend du texte . on n essaye pas de transformer
68 def __init__(self,node,monSimpDef,nom,objSimp,parentQt,commande):
70 MonWidgetPlusieursInto.__init__(self,node,monSimpDef,nom,objSimp,parentQt,commande)
71 self.lineEditVal.returnPressed.connect(self.LEValeurAjouteDsPossible)