1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2017 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
23 from __future__ import absolute_import
25 from builtins import str
28 from desSelectVal import Ui_DSelVal
29 from Extensions.i18n import tr
31 from PyQt5.QtWidgets import QDialog, QFileDialog
32 from PyQt5.QtCore import QTimer, Qt
33 from PyQt5.QtGui import QPalette
35 class DSelVal(Ui_DSelVal,QDialog):
36 def __init__(self,parent ,modal ) :
37 QDialog.__init__(self,parent)
40 class MonSelectVal(DSelVal):
42 Classe definissant le panel associe aux mots-cles qui demandent
43 a l'utilisateur de choisir une seule valeur parmi une liste de valeurs
46 def __init__(self,file,parent,name = None,fl = 0):
49 DSelVal.__init__(self,parent,0)
56 self.connecterSignaux()
58 def connecterSignaux(self) :
59 self.Bespace.clicked.connect(self.SelectEsp)
60 self.BpointVirgule.clicked.connect(self.SelectPoint)
61 self.Bvirgule.clicked.connect(self.SelectVir)
62 self.BImportSel.clicked.connect(self.BImportSelPressed)
63 self.BImportTout.clicked.connect(self.BImportToutPressed)
64 self.parent.editor.sb.messageChanged.connect(self.messageAChanger)
66 def connecterSignauxQT4(self) :
67 self.connect(self.Bespace,SIGNAL("clicked()"),self.SelectEsp)
68 self.connect(self.BpointVirgule,SIGNAL("clicked()"),self.SelectPoint)
69 self.connect(self.Bvirgule,SIGNAL("clicked()"),self.SelectVir)
70 self.connect(self.BImportSel,SIGNAL("clicked()"),self.BImportSelPressed)
71 self.connect(self.BImportTout,SIGNAL("clicked()"),self.BImportToutPressed)
72 self.connect(self.parent.editor.sb,SIGNAL("messageChanged(QString)"),self.messageAChanger)
74 def messageAChanger(self):
75 message=self.parent.editor.sb.currentMessage()
76 mapalette=self.sb.palette()
77 mapalette.setColor( QPalette.Text,Qt.red )
78 self.sb.setPalette( mapalette )
79 self.sb.setText(message)
80 QTimer.singleShot(3000, self.efface)
86 if self.file == "" : return
87 f = open(self.file, "r")
93 self.TBtext.setText(self.texte)
101 def SelectPoint(self):
104 def BImportSelPressed(self):
106 texte = self.TBtext.textCursor().selectedText()
107 textTraite=texte.replace(u'\u2029',"\n")
108 self.textTraite=str(textTraite)
111 def BImportToutPressed(self):
112 self.textTraite=self.texte
115 def Traitement(self):
116 if self.textTraite == "" : return
117 if self.textTraite[-1]=="\n" : self.textTraite=self.textTraite[0:-1]
118 self.textTraite=self.textTraite.replace("\n",self.separateur)
119 liste1=self.textTraite.split(self.separateur)
122 if val != '' and val != ' ' and val != self.separateur :
129 self.parent.ajoutNValeur(liste)