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 # ======================================================================
21 Ce module contient la classe APPLI qui est la classe mère de
22 l'application EFICAS. Elle prend en charge l'organisation générale
23 des composants graphiques et l'initialisation Tk
24 L'aspect applicatif doit etre pris en charge par la classe dérivée
31 from tkMessageBox import showinfo,askyesno,showerror
39 from widgets import Fenetre
40 from Misc import MakeNomComplet
45 def __init__ (self,master,code='ASTER',fichier=None) :
48 self.top.protocol("WM_DELETE_WINDOW",self.exitEFICAS)
49 self.top.minsize(900,500)
50 self.top.geometry("900x500")
51 self.top.title(VERSION + ' pour '+self.code)
53 self.initializeTk(master)
54 Pmw.initialise(master)
55 self.lecture_parametres()
56 self.format_fichier = Tkinter.StringVar()
58 self.cree_composants_graphiques()
59 self.load_appli_composants() # Creation du BUREAU
62 # AY : cas ou le nom du fichier a été passé en argument
65 self.bureau.openJDC( str(MakeNomComplet.FILENAME(fichier)) )
67 showerror( "ARGUMENT INVALIDE", str(e) )
70 def send_message(self,message):
79 def lecture_parametres(self):
81 Active la lecture des paramètres standards et utilisateur
83 splash._splash.configure(text = "Chargement des paramètres utilisateur")
85 self.CONFIGURATION = configuration.make_config(self,prefs.REPINI)
87 def cree_composants_graphiques(self):
89 Cree les constituants de l'application :
95 splash._splash.configure(text = "Chargement de l'IHM")
96 splash._splash.configure(text = "Chargement de la menubar")
98 self.menubar=menubar.MENUBAR(self,self.top)
99 splash._splash.configure(text = "Chargement de la toolbar")
101 self.toolbar=toolbar.TOOLBAR(self,self.top)
102 splash._splash.configure(text = "Chargement de la statusbar")
104 self.statusbar=statusbar.STATUSBAR(self.top)
106 def load_appli_composants(self):
107 splash._splash.configure(text = "Chargement des appli_composants")
108 for mname in self.appli_composants:
109 self.load_appli_composant(mname)
111 def load_appli_composant(self,mname):
112 module=__import__(mname,globals(),locals())
113 factory=getattr(module,mname.upper())
114 appli_composant=factory(self,self.top)
115 setattr(self,mname,appli_composant)
116 self.fill_menus(appli_composant,appli_composant.menu_defs)
117 self.toolbar.creer_boutons_appli_composant(appli_composant.button_defs,appli_composant)
119 def affiche_FAQ(self):
121 faq.affiche(self.top)
123 def affiche_infos(self,message):
124 self.statusbar.affiche_infos(message)
127 def initializeTk(self, root):
129 Initialize platform specific options
131 if sys.platform == 'mac':
132 self.initializeTk_mac(root)
133 elif sys.platform == 'win32':
134 self.initializeTk_win32(root)
136 self.initializeTk_unix(root)
138 def initializeTk_win32(self, root):
139 root.option_add('*Font', fontes.standard)
140 root.option_add('*EntryField.Entry.Font', fontes.standard)
141 root.option_add('*Listbox*Font',fontes.standard)
143 def initializeTk_colors_common(self, root):
144 root.option_add('*background', 'grey')
145 root.option_add('*foreground', 'black')
146 root.option_add('*EntryField.Entry.background', 'white')
147 root.option_add('*Entry*background', 'white')
148 root.option_add('*Listbox*background', 'white')
149 root.option_add('*Listbox*selectBackground', '#00008b')
150 root.option_add('*Listbox*selectForeground', 'white')
152 def initializeTk_mac(self, root):
153 self.initializeTk_colors_common(root)
155 def initializeTk_unix(self, root):
156 root.option_add('*Font', fontes.standard)
157 root.option_add('*EntryField.Entry.Font',fontes.standard )
158 root.option_add('*Listbox*Font', fontes.standard)
159 self.initializeTk_colors_common(root)
161 def get_texte_infos(self):
163 Retourne un texte d'informations sur la session courante d'EFICAS
165 texte = VERSION + '\n\n'
166 texte = texte + 'EFICAS est un produit développé par \nEDF-Division Stratégie et Développement\n'
167 texte = texte + 'Equipe : MTI/MMN\n\n'
168 texte = texte + 'Code utilisé : %s version %s\n' % (self.code,properties.version)
171 def efface_aide(self,event):
173 Efface la bulle d'aide d'un panneau
181 def affiche_aide(self,event,aide):
183 Affiche l'aide concernant un panneau
188 self.aide=tooltip.TOOLTIP(widget)
189 self.aide.xoffset = 10
190 self.aide.yoffset = - widget.winfo_height()/2
191 self.aide.setText(aide)
195 def cree_menu(self,menu,itemlist,appli_composant):
197 Ajoute les items du tuple itemlist
202 for item in itemlist:
203 number_item=number_item + 1
208 if type(method) == types.TupleType:
209 # On a un tuple => on cree une cascade
210 menu_cascade=Tkinter.Menu(menu)
211 menu.add_cascade(label=label,menu=menu_cascade)
212 self.cree_menu(menu_cascade,method,appli_composant)
213 elif method[0] == '&':
214 # On a une chaine avec & en tete => on cree un radiobouton
215 command=getattr(appli_composant,method[1:])
216 menu.add_radiobutton(label=label,command=command)
217 if radio == None:radio=number_item
219 command=getattr(appli_composant,method)
220 menu.add_command(label=label,command=command)
221 # Si au moins un radiobouton existe on invoke le premier
222 if radio:menu.invoke(radio)
224 def fill_menus(self,appli_composant,defs):
225 menudict=self.menubar.menudict
226 for mname,itemlist in defs:
227 menu=menudict.get(mname)
229 self.cree_menu(menu,itemlist,appli_composant)
231 def update_jdc_courant(self):
232 self.bureau.update_jdc_courant()
234 def affiche_alerte(self,titre,message):
235 f=Fenetre(self, titre="Compte-rendu d'erreur", texte = titre + "\n\n" + message)