Salome HOME
mise a jour du COPYRIGHT
[tools/eficas.git] / Editeur / appli.py
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.
8 #
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.
13 #
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.
17 #
18 #
19 # ======================================================================
20 """
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
25 """
26 # Modules Python
27 import sys
28 import Pmw
29 import Tkinter
30
31 # Modules Eficas
32 import splash
33 import prefs
34 import fontes
35
36 class APPLI: 
37   def __init__ (self,master,code='ASTER',fichier=None) :
38       self.top=master
39       self.code=code
40       self.top.protocol("WM_DELETE_WINDOW",self.exitEFICAS)
41       self.top.minsize(900,500)
42       self.top.geometry("900x500")
43       self.top.title('EFICAS v1.1 pour '+self.code)
44       self.top.withdraw()
45       self.initializeTk(master)
46       Pmw.initialise(master)
47       self.lecture_parametres()
48       self.format_fichier = Tkinter.StringVar()
49       self.message=''
50       self.cree_composants_graphiques()
51       self.load_extensions()
52       self.affiche_FAQ()
53       splash.fini_splash()
54
55   def send_message(self,message):
56       self.message=message
57
58   def exitEFICAS(self):
59       self.quit()
60
61   def quit(self):
62       self.top.quit()
63
64   def lecture_parametres(self):
65       """
66           Active la lecture des paramètres standards et utilisateur
67       """
68       splash._splash.configure(text = "Chargement des paramètres utilisateur")
69       import configuration
70       self.CONFIGURATION = configuration.make_config(self,prefs.REPINI)
71
72   def cree_composants_graphiques(self):
73       """
74           Cree les constituants de l'application :
75            - menubar
76            - tollbar
77            - bureau
78            - statusbar
79       """
80       splash._splash.configure(text = "Chargement de l'IHM")
81       splash._splash.configure(text = "Chargement de la menubar")
82       import menubar
83       self.menubar=menubar.MENUBAR(self,self.top)
84       splash._splash.configure(text = "Chargement de la toolbar")
85       import toolbar
86       self.toolbar=toolbar.TOOLBAR(self,self.top)
87       splash._splash.configure(text = "Chargement de la statusbar")
88       import statusbar
89       self.statusbar=statusbar.STATUSBAR(self.top)
90
91   def load_extensions(self):
92       splash._splash.configure(text = "Chargement des extensions")
93       for mname in self.extensions:
94          self.load_extension(mname)
95
96   def load_extension(self,mname):
97       module=__import__(mname,globals(),locals())
98       factory=getattr(module,mname.upper())
99       extension=factory(self,self.top)
100       setattr(self,mname,extension)
101       self.fill_menus(extension,extension.menu_defs)
102       self.toolbar.creer_boutons_extension(extension.button_defs,extension)
103
104   def affiche_FAQ(self):
105       import faq
106       faq.affiche(self.top)
107
108   def affiche_infos(self,message):
109       self.statusbar.affiche_infos(message)
110       return
111
112   def  initializeTk(self, root):
113         """
114         Initialize platform specific options
115         """
116         if sys.platform == 'mac':
117             self.initializeTk_mac(root)
118         elif sys.platform == 'win32':
119             self.initializeTk_win32(root)
120         else:
121             self.initializeTk_unix(root)
122
123   def initializeTk_win32(self, root):
124         root.option_add('*Font', fontes.standard)
125         root.option_add('*EntryField.Entry.Font', fontes.standard)
126         root.option_add('*Listbox*Font',fontes.standard)
127
128   def initializeTk_colors_common(self, root):
129         root.option_add('*background', 'grey')
130         root.option_add('*foreground', 'black')
131         root.option_add('*EntryField.Entry.background', 'white')
132         root.option_add('*Entry*background', 'white')
133         root.option_add('*Listbox*background', 'white')
134         root.option_add('*Listbox*selectBackground', '#00008b')
135         root.option_add('*Listbox*selectForeground', 'white')
136
137   def initializeTk_mac(self, root):
138         self.initializeTk_colors_common(root)
139
140   def initializeTk_unix(self, root):
141       root.option_add('*Font', fontes.standard)
142       root.option_add('*EntryField.Entry.Font',fontes.standard )
143       root.option_add('*Listbox*Font', fontes.standard)
144       self.initializeTk_colors_common(root)
145
146   def get_texte_infos(self):
147       """
148           Retourne un texte d'informations sur la session courante d'EFICAS
149       """
150       texte = 'EFICAS v1.1\n\n'
151       texte = texte + 'EFICAS est un produit développé par \nEDF-Division Stratégie et Développement\n'
152       texte = texte + 'Equipe : MTI/MMN\n\n'
153       texte = texte + 'Code utilisé : %s\n' %self.code
154       return texte
155
156   def efface_aide(self,event):
157       """
158           Efface la bulle d'aide d'un panneau
159       """
160       try:
161           self.aide.destroy()
162       except:
163           pass
164       return
165
166   def affiche_aide(self,event,aide):
167       """
168           Affiche l'aide concernant un panneau
169       """
170       x=event.x
171       y=event.y
172       widget=event.widget
173       self.aide = Tkinter.Label(widget ,text = aide,
174                         bg="yellow",relief="ridge",anchor='w')
175       self.aide.place(in_=widget,
176                       relx=0.5,rely=0.5,anchor='center')
177       print aide
178       return
179
180   def fill_menus(self,extension,defs):
181       menudict=self.menubar.menudict
182       for mname,itemlist in defs:
183           menu=menudict.get(mname)
184           if not menu:continue
185           for item in itemlist:
186              if not item :
187                 menu.add_separator()
188              else:
189                 label,method=item
190                 command=getattr(extension,method)
191                 menu.add_command(label=label,command=command)
192                 
193