Salome HOME
c2a9d3945d83ca765275cbc0457287972438a0b3
[modules/eficas.git] / src / EFICASGUI / eficasEtude.py
1 #=============================================================================
2 # File      : EficasEtude.py
3 # Created   : mar fév 25 09:48:34 CET 2003
4 # Author    : Pascale NOYRET, EDF
5 # Project   : SALOME
6 # Copyright : EDF 2003
7 #  $Header: /home/salome/PlateFormePAL/Bases_CVS_EDF/Modules_EDF/ASTER_SRC/src/ASTERGUI/eficasEtude.py,v 1.1.1.1.2.1 2004/05/18 11:40:21 salome Exp $
8 #=============================================================================
9
10 import salome
11 import re
12 from tkFileDialog import asksaveasfilename
13
14 import salomedsgui
15 aGuiDS=salomedsgui.guiDS()
16
17 #--------------------------------------------------------------------------
18
19 class Eficas_In_Study:
20
21       def __init__(self):
22           import SMESH_utils
23           self.enregistre()
24           self.liste_deja_la=[]
25           
26       def  enregistre(self):
27            self.fatherId=aGuiDS.enregistre("Eficas")
28            salome.sg.updateObjBrowser(0)
29
30       def  rangeInStudy(self,fichier):
31            if fichier not in self.liste_deja_la :
32                 self.liste_deja_la.append(fichier)
33                 Nom=re.split("/",fichier)[-1]
34
35                 self.commId=aGuiDS.createItemInStudy(self.fatherId,Nom)
36                 aGuiDS.setExternalFileAttribute(self.commId,"FICHIER_EFICAS",fichier)
37                 salome.sg.updateObjBrowser(0)
38
39       def creeConfigTxt(self,fichier,dico):
40            sauvegarde = asksaveasfilename(title="fichier config.txt",
41                                      defaultextension='.txt',
42                                      initialdir = fichier)
43            f=open(sauvegarde,'w+')
44            for unite in dico.keys():
45                 print unite
46                 type=dico[unite][0]
47                 fic=dico[unite][1:]
48                 ligne="fort."+str(unite)+" "+type+" "+fic
49                 f.write(ligne)
50            f.close()
51            self.rangeInStudy(sauvegarde)
52