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 # ======================================================================
31 def __init__(self,appli,parent):
32 # parent représente l'objet graphique parent
34 # appli représente l'objet application parent
37 self.l_boutons_a_activer = []
38 self.barreboutons=Frame(self.parent,relief='ridge',bd=2)
39 self.barreboutons.pack(anchor='nw',expand=0,fill=X)
40 # bouton Infos à l'extrême droite de la barre des boutons
41 b = Button(self.barreboutons,
42 image = images.get_image('About24'),
43 command = self.view_infos)
45 texte = "Infos EFICAS"
46 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t,pos='right'))
47 b.bind("<Leave>", self.efface_balloon)
51 def creer_boutons(self):
52 self.l_boutons = (('New24',self.appli.newJDC,"Création d'un nouveau fichier",'always'),
53 ('Open24',self.appli.openJDC,"Ouverture d'un fichier existant",'always'),
54 ('Save24',self.appli.saveJDC,"Sauvegarde du fichier courant",'always'),
55 ('Zoom24',self.appli.visuJDC,"Visualisation du fichier de commandes",'always'),
57 ('Copy24',self.appli.copy,"Copie l'objet courant",'jdc'),
58 ('Cut24',self.appli.cut,"Coupe l'objet courant",'jdc'),
59 ('Paste24',self.appli.paste,"Colle l'objet copié après l'objet courant",'jdc'),
61 ('Delete24',self.appli.delete,"Supprime l'objet courant",'jdc'),
62 ('Help24',self.appli.view_doc,"Documentation de l'objet courant",'jdc')
64 # liste des boutons à activer quand statut != 'always'
65 self.l_boutons_a_activer = []
67 for bouton in self.l_boutons :
69 # on veut afficher un bouton vide (=espace entre boutons)
70 Button(self.barreboutons,
71 image = images.get_image('New24'),
72 relief = 'flat').pack(side='left')
74 nom_fic,commande,texte,statut = bouton
75 b = Button(self.barreboutons,
76 image = images.get_image(nom_fic),
80 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t))
81 b.bind("<Leave>", self.efface_balloon)
82 if statut != 'always':
83 self.l_boutons_a_activer.append(b)
84 # bouton Infos à l'extrême droite de la barre des boutons
85 b = Button(self.barreboutons,
86 image = images.get_image('About24'),
87 command = self.view_infos)
89 texte = "Infos EFICAS"
90 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t,pos='right'))
91 b.bind("<Leave>", self.efface_balloon)
92 # inactive les boutons qui doivent l'être tant qu'aucun JDC courant
93 self.inactive_boutons()
95 def inactive_boutons(self):
97 Inactive les boutons de la liste self.l_boutons_a_activer
98 --> cette méthode est appelée dès qu'il n'y a pas de JDC courant
100 for but in self.l_boutons_a_activer:
101 but.configure(state='disabled')
103 def active_boutons(self):
105 Active les boutons de la liste self.l_boutons_a_activer
106 --> cette méthode est appelée dès qu'il y a un JDC courant
108 for but in self.l_boutons_a_activer:
109 but.configure(state='normal')
111 def affiche_balloon(self,event,bouton,bulle,pos='left'):
113 Affiche le balloon bulle associé au bouton bouton
115 etat = bouton.cget('state')
116 if etat != 'normal' : return
117 geom = bouton.winfo_geometry()
118 l_args = string.split(geom,'+')
119 x = eval(l_args[1])+event.x+10
120 self.balloon = Label(self.parent,
126 self.balloon.place(in_=self.parent,x=x,y=32)
128 self.balloon.place(in_=self.parent,x=x,y=32,anchor='ne')
130 def efface_balloon(self,event=None):
132 Efface le balloon courant
135 self.balloon.destroy()
138 def view_infos(self):
140 Permet d'afficher des infos sur la session courante d'EFICAS
142 self.fen_infos = Pmw.Dialog(self.parent,
143 title = 'Informations session EFICAS',
144 buttons = ('Fermer',),
145 command = self.close_infos)
146 self.fen_infos.withdraw()
147 texte_infos = self.appli.get_texte_infos()
148 Label(self.fen_infos.interior(),
150 anchor='center').pack(side='top',anchor='center')
151 self.fen_infos.activate(geometry = 'centerscreenalways')
153 def close_infos(self,lbl):
155 Ferme la fenêtre des infos
157 self.fen_infos.destroy()
159 def creer_boutons_appli_composant(self,l_boutons,appli_composant):
160 for bouton in l_boutons :
162 # on veut afficher un bouton vide (=espace entre boutons)
163 Button(self.barreboutons,
164 image = images.get_image('New24'),
165 relief = 'flat').pack(side='left')
167 nom_fic,commande,texte,statut = bouton
168 commande=getattr(appli_composant,commande)
169 b = Button(self.barreboutons,
170 image = images.get_image(nom_fic),
174 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t))
175 b.bind("<Leave>", self.efface_balloon)
176 if statut != 'always':
177 self.l_boutons_a_activer.append(b)
179 # inactive les boutons qui doivent l'être tant qu'aucun JDC courant
180 self.inactive_boutons()