Salome HOME
PN
[tools/eficas.git] / Editeur / options.py
1 # -*- coding: utf-8 -*-
2 #            CONFIGURATION MANAGEMENT OF EDF VERSION
3 # ======================================================================
4 # COPYRIGHT (C) 1991 - 2002  EDF R&D                  WWW.CODE-ASTER.ORG
5 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
6 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
7 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
8 # (AT YOUR OPTION) ANY LATER VERSION.
9 #
10 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
11 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
12 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
13 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 #
15 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
16 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
17 #    1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
18 #
19 #
20 # ======================================================================
21 """
22 """
23 # Modules Python
24 import os,string
25
26 # Modules Eficas
27 from widgets import askopenfilename
28 import panels
29
30 # l'option affichage_commandes peut prendre les valeurs "groupes" ou "alphabetic"
31 affichage_commandes="alphabetic"
32
33 class OPTIONS:
34
35    menu_defs=[
36         ('Options',[
37                    ("Affichage commandes",(("alphabétique",'&affichage_alpha'),("groupes",'&affichage_grp'))),
38                    #("Couleur",(("fond",'change_fond'),("barre",'change_barre'))),
39                    # ("Catalogue développeur",'choix_cata_developpeur'),
40                    ('Paramètres Eficas','affichage_fichier_ini'),
41                       
42                    ]
43         )
44              ]
45
46    button_defs=[]
47
48    def __init__(self,appli,parent):
49       self.appli=appli
50       self.parent=parent
51
52
53    def affichage_grp(self):
54       global affichage_commandes
55       affichage_commandes="groupes"
56       if hasattr(panels,'panneauCommande'):
57          panel=panels.panneauCommande
58          parent=panel.parent
59          if parent != None :
60             parent.create_panel(parent.node_selected)
61             # si on a un panel avec plusieurs onglets
62             # on affiche Commande
63             try :
64               parent.panel_courant.nb.selectpage("Commande")
65             except :
66               pass
67
68    def affichage_alpha(self):
69
70       global affichage_commandes
71       affichage_commandes="alphabetic"
72       if hasattr(panels,'panneauCommande'):
73          panel=panels.panneauCommande
74          parent=panel.parent
75          if parent != None :
76             parent.create_panel(parent.node_selected)
77             # si on a un panel avec plusieurs onglets
78             # on affiche Commande
79             try :
80               parent.panel_courant.nb.selectpage("Commande")
81             except :
82               pass
83
84    def change_fond(self):
85       from tkColorChooser import askcolor
86       #nouvelle=askcolor(self.appli.background)
87       nouvelle=askcolor('grey')
88
89    def change_barre(self):
90        pass
91
92    def choix_cata_developpeur(self):
93       """ 
94           Cette méthode demande à l'utilisateur-développeur d'indiquer quel catalogue
95           il veut utiliser en remplacement du catalogue standard du code
96           NB : il faut que le développeur ait les droits d'écriture dans le répertoire où
97           se trouve le catalogue 
98       """
99       file = askopenfilename(title="Choix d'un catalogue personnel",
100                              defaultextension=".py",
101                              filetypes = ( ("Catalogue", "cata*.py"),))
102       if file :
103           self.parent.update_idletasks()
104           self.appli.reset_affichage_infos()
105           rep_fic = os.path.dirname(file)
106           nom_fic = string.split(os.path.basename(file),'.')[0]
107           rep_courant = os.getcwd()
108           os.chdir(rep_fic)
109           self.cata = __import__(nom_fic)
110           self.code = self.cata.CODE
111           os.chdir(rep_courant)
112           self.fic_cata = file
113           fic_cata_p = nom_fic+'_pickled.py'
114           self.fic_cata_p = os.path.join(rep_fic,fic_cata_p)
115           pile_erreurs = self.cata.erreurs_cata
116           if pile_erreurs.existe_message() :
117               messages = pile_erreurs.retourne_messages()
118               print messages
119           else :
120               # XXX ne doit pas fonctionner
121               self.catalo = catabrowser.CataItem(cata=self.cata)
122               self.Retrouve_Ordre_Cata('personnel')
123           pile_erreurs.efface()
124
125
126    def affichage_fichier_ini(self):
127        self.appli.bureau.affichage_fichier_ini()