1 # CONFIGURATION MANAGEMENT OF EDF VERSION
2 # ======================================================================
3 # COPYRIGHT (C) 1991 - 2002 EDF R&D WWW.CODE-ASTER.ORG
4 # THIS PROGRAM IS FREE SOFTWARE; YOU CAN REDISTRIBUTE IT AND/OR MODIFY
5 # IT UNDER THE TERMS OF THE GNU GENERAL PUBLIC LICENSE AS PUBLISHED BY
6 # THE FREE SOFTWARE FOUNDATION; EITHER VERSION 2 OF THE LICENSE, OR
7 # (AT YOUR OPTION) ANY LATER VERSION.
9 # THIS PROGRAM IS DISTRIBUTED IN THE HOPE THAT IT WILL BE USEFUL, BUT
10 # WITHOUT ANY WARRANTY; WITHOUT EVEN THE IMPLIED WARRANTY OF
11 # MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. SEE THE GNU
12 # GENERAL PUBLIC LICENSE FOR MORE DETAILS.
14 # YOU SHOULD HAVE RECEIVED A COPY OF THE GNU GENERAL PUBLIC LICENSE
15 # ALONG WITH THIS PROGRAM; IF NOT, WRITE TO EDF R&D CODE_ASTER,
16 # 1 AVENUE DU GENERAL DE GAULLE, 92141 CLAMART CEDEX, FRANCE.
19 # ======================================================================
27 from centerwindow import centerwindow
29 class fenetre_mc_inconnus :
31 Cette classe sert à construire la fenêtre qui apparaît dans EFICAS
32 lorsque des mots-clés inconnus ont été trouvés dans le fichier de
33 commandes que l'on est en train de lire
35 def __init__(self,l_mc):
37 self.fenetre = Toplevel()
38 self.fenetre.geometry("400x400+0+0")
39 self.fenetre.title("Mots-clés inconnus dans le fichier de commandes")
45 centerwindow(self.fenetre)
49 Initialise les structures de données
53 self.new_l_mc.append(copy.copy(mc))
54 self.mc_courant = None
55 self.var_quit = IntVar(0)
56 self.entry_courante = None
58 def init_frames(self):
60 Création des 2 frames devant contenir le label et la liste des MC inconnus
62 self.frame1 = Frame(self.fenetre)
63 self.frame2 = Frame(self.fenetre)
64 self.frame3 = Frame(self.fenetre)
65 self.frame1.place(relx=0,rely=0,relheight=0.2,relwidth=1)
66 self.frame2.place(relx=0,rely=0.2,relheight=0.6,relwidth=1)
67 self.frame3.place(relx=0,rely=0.8,relheight=0.2,relwidth=1)
71 Affichage du label dans la zone concernée
73 txt = " Un ou plusieurs mots-clés inconnus ont été trouvés dans le fichier de commandes."
74 #txt = txt + "En cliquant sur leur nom, vous pourrez soit corriger l'orthographe soit supprimer ce mot-clé"
75 self.fenetre.update_idletasks()
78 wraplength = int(self.frame1.winfo_width()*0.8),
79 justify = 'center').place(relx=0.5,rely=0.5,anchor='center')
82 def init_liste_mc(self):
84 Affiche les mots-clés à modifier ou supprimer
90 # mc contient comme premiers arguments l'étape et éventuellement les blocs, mcfact ...
91 # et contient comme 2 derniers éléments le nom du mot-clé et sa valeur
92 path_mc = self.get_path(mc[0:-2])
94 lab=Label(self.frame2,text = path_mc)
95 lab.grid(row=i,column=1,sticky=W)
96 e = Entry(self.frame2)
97 e.grid(row=i,column=0,sticky=W)
99 #e.bind("<Button-1>",lambda event,en=e,m=mc,s=self : s.select_mc(m,en))
100 #e.bind("<Return>",lambda e,s=self : s.modifie_mc())
101 e.configure(relief='flat',state='disabled')
102 self.widgets.append((e,lab))
105 def init_boutons(self):
107 Construit les boutons Modifier,Supprimer et Fermer
108 Les deux premiers sont inactifs tant qu'aucun mot-clé n'est sélectionné
110 self.b_mod = Button(self.frame3,
112 disabledforeground = 'grey35',
114 command = self.modifie_mc)
115 self.b_sup = Button(self.frame3,
117 disabledforeground = 'grey35',
119 command = self.supprime_mc)
120 self.b_quit = Button(self.frame3,
123 #self.b_mod.place(relx=0.25,rely=0.5,anchor='center')
124 #self.b_sup.place(relx=0.50,rely=0.5,anchor='center')
125 #self.b_quit.place(relx=0.75,rely=0.5,anchor='center')
126 self.b_quit.place(relx=0.50,rely=0.5,anchor='center')
128 def wait_new_list(self):
130 Cette méthode rend cette toplevel bloquante.
131 Dès que la variable var_quit est modifiée, on continue l'exécution de cette
132 méthode (et on quitte)
134 self.fenetre.wait_variable(self.var_quit)
135 self.fenetre.destroy()
138 def get_path(self,l_o):
140 Construit la chaîne de caractère contenant le chemin d'accès complet du mot-clé
144 txt = txt + o.nom+'/'
145 # on enlève le dernier slash en trop
149 def select_mc(self,mc,entry):
151 Enregistre le mot-clé passé en argument comme mot-clé courant
152 Active les boutons Modifier et Supprimer
154 self.desactive_entry()
156 self.entry_courante = entry
157 self.active_boutons()
160 def modifie_mc(self):
162 Modifie le nom du mot-clé en prenant la nouvelle valeur lue dans entry_courante
164 new_nom_mc = self.entry_courante.get()
165 index = self.l_mc.index(self.mc_courant)
166 new_mc = self.new_l_mc[index]
167 new_mc[-2] = new_nom_mc
168 objet_pere = self.mc_courant[-3]
170 self.desactive_boutons()
171 self.desactive_entry()
173 def supprime_mc(self):
175 Supprime le mot-clé courant de la liste
177 index = self.l_mc.index(self.mc_courant)
178 self.new_l_mc[index] = None
179 e,lab=self.widgets[index]
182 self.desactive_boutons()
183 self.desactive_entry()
185 def desactive_boutons(self):
187 Désactive les boutons Modifier et Supprimer
189 self.b_mod.configure(state='disabled')
190 self.b_sup.configure(state='disabled')
192 def active_boutons(self):
194 Active les boutons Modifier et Supprimer
196 self.b_mod.configure(state='normal')
197 self.b_sup.configure(state='normal')
199 def desactive_entry(self):
201 Désactive l'entry courante si elle existe
203 if self.entry_courante :
204 self.entry_courante.configure(state='disabled',relief='flat')
206 def active_entry(self):
208 Active l'entry courante si elle existe
210 if self.entry_courante :
211 self.entry_courante.configure(state='normal',relief='sunken')
215 Permet de fermer la fenêtre
219 if __name__ == '__main__':
220 fenetre_mc_inconnus(('toto','titi'))