]> SALOME platform Git repositories - tools/eficas.git/blob - InterfaceQT4/monChoixCode.py
Salome HOME
34ef7c28446c3324d642384ba6f593b41274dd6e
[tools/eficas.git] / InterfaceQT4 / monChoixCode.py
1 # -*- coding: utf-8 -*-
2 # Copyright (C) 2007-2013   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 # Modules Eficas
22
23 import os,sys,re
24 from desChoixCode import Ui_ChoixCode
25 from determine import monEnvQT5
26 if monEnvQT5:
27     from PyQt5.QtWidgets import QDialog, QRadioButton
28     from PyQt5.QtGui import QPalette
29     from PyQt5.QtCore import QProcess, QFileInfo, Qt, QSize
30 else :
31     from PyQt4.QtGui  import *
32     from PyQt4.QtCore import *
33
34     
35 # Import des panels
36
37 class MonChoixCode(Ui_ChoixCode,QDialog):
38   """
39   Classe définissant le panel associé aux mots-clés qui demandent
40   à l'utilisateur de choisir une seule valeur parmi une liste de valeurs
41   discrètes
42   """
43   def __init__(self,  parentAppli=None):
44       QDialog.__init__(self,parentAppli)
45       self.setModal(True)
46       self.setupUi(self)
47       self.parentAppli=parentAppli
48       self.verifieInstall()
49       self.code=None
50       if monEnvQT5:
51          self.pB_OK.clicked.connect(self.choisitCode)
52          self.pB_cancel.clicked.connect(self.sortie)
53       else :
54          self.connect(self.pB_OK,SIGNAL("clicked()"),self.choisitCode)
55          self.connect(self.pB_cancel,SIGNAL("clicked()"),self.sortie)
56
57   def sortie(self):
58       QDialog.reject(self)
59
60   def verifieInstall(self):
61       self.groupCodes=QButtonGroup(self.groupBox)
62       vars=os.environ.items()
63       listeCode=('Aster','Adao','Carmel3D','CarmelCND','CF','MAP','MT','PSEN','Telemac','ZCracks',)
64       i=1
65       for code in listeCode:
66           nom='rB_'+code
67           dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
68           try :
69              l=os.listdir(dirCode)
70              bouton=QRadioButton(self)
71              bouton.setMinimumSize(QSize(0, 30))
72              bouton.setText(code)
73              bouton.setGeometry(QRect(10,20+30*i, 300, 30))
74              bouton.show()
75              self.groupCodes.addButton(bouton)
76              i=i+1
77           except :
78              clef="PREFS_CATA_"+code
79              try :
80                 repIntegrateur=os.path.abspath(os.environ[clef])
81                 l=os.listdir(repIntegrateur)
82                 bouton=QRadioButton(self)
83                 bouton.setGeometry(QRect(10,20+30*i, 300, 30))
84                 bouton.setMinimumSize(QSize(0, 30))
85                 bouton.setText(code)
86                 bouton.show()
87                 i=i+1
88                 self.groupCodes.addButton(bouton)
89              except :
90                 pass
91       listeCodesIntegrateur=[]
92       for k,v in vars:
93           if re.search('^PREFS_CATA_',k) != None and k[11:] not in listeCode:
94              listeCodesIntegrateur.append(k[11:])
95       for code in listeCodesIntegrateur:
96           try :
97               clef="PREFS_CATA_"+code
98               repIntegrateur=os.path.abspath(os.environ[clef])
99               l=os.listdir(repIntegrateur)
100               bouton=QRadioButton(self)
101               bouton.setGeometry(QRect(10,20+30*i, 300, 30))
102               i=i+1
103               bouton.setMinimumSize(QSize(0, 30))
104               bouton.setText(code)
105               bouton.show()
106               self.groupCodes.addButton(bouton)
107           except :
108               pass
109       self.parentAppli.ListeCode=self.parentAppli.ListeCode+listeCodesIntegrateur
110
111   def choisitCode(self):
112       bouton=self.groupCodes.checkedButton()
113       code=str(bouton.text())
114       codeUpper=code.upper()
115       self.parentAppli.code=codeUpper
116       try :
117           dirCode=os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',code))
118           l=os.listdir(dirCode)
119           sys.path.insert(0,dirCode)
120       except :
121           clef="PREFS_CATA_"+code
122           repIntegrateur=os.path.abspath(os.environ[clef])
123           l=os.listdir(repIntegrateur)
124           sys.path.insert(0,repIntegrateur)
125       self.close()