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.
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.
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.
20 # ======================================================================
32 def __init__(self,appli,parent):
33 # parent représente l'objet graphique parent
35 # appli représente l'objet application parent
38 self.l_boutons_a_activer = []
39 self.barreboutons=Frame(self.parent,relief='ridge',bd=2)
40 self.barreboutons.pack(anchor='nw',expand=0,fill=X)
41 # bouton Infos à l'extrême droite de la barre des boutons
42 b = Button(self.barreboutons,
43 image = images.get_image('About24'),
44 command = self.view_infos)
46 texte = "Infos EFICAS"
47 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t,pos='right'))
48 b.bind("<Leave>", self.efface_balloon)
50 def appelle_commande(self,e,b,c):
56 def inactive_boutons(self):
58 Inactive les boutons de la liste self.l_boutons_a_activer
59 --> cette méthode est appelée dès qu'il n'y a pas de JDC courant
61 for but in self.l_boutons_a_activer:
62 but.configure(state='disabled')
64 def active_boutons(self):
66 Active les boutons de la liste self.l_boutons_a_activer
67 --> cette méthode est appelée dès qu'il y a un JDC courant
69 for but in self.l_boutons_a_activer:
70 but.configure(state='normal')
72 def affiche_balloon(self,event,bouton,bulle,pos='left'):
74 Affiche le balloon bulle associé au bouton bouton
76 etat = bouton.cget('state')
77 if etat != 'normal' : return
78 geom = bouton.winfo_geometry()
79 l_args = string.split(geom,'+')
80 x = eval(l_args[1])+event.x+10
81 self.balloon = Label(self.parent,
87 self.balloon.place(in_=self.parent,x=x,y=32)
89 self.balloon.place(in_=self.parent,x=x,y=32,anchor='ne')
91 def efface_balloon(self,event=None):
93 Efface le balloon courant
96 self.balloon.destroy()
101 Permet d'afficher des infos sur la session courante d'EFICAS
103 self.fen_infos = Pmw.Dialog(self.parent,
104 title = 'Informations session EFICAS',
105 buttons = ('Fermer',),
106 command = self.close_infos)
107 self.fen_infos.withdraw()
108 texte_infos = self.appli.get_texte_infos()
109 Label(self.fen_infos.interior(),
111 anchor='center').pack(side='top',anchor='center')
112 self.fen_infos.activate(geometry = 'centerscreenalways')
114 def close_infos(self,lbl):
116 Ferme la fenêtre des infos
118 self.fen_infos.destroy()
120 def creer_boutons_appli_composant(self,l_boutons,appli_composant):
121 for bouton in l_boutons :
123 # on veut afficher un bouton vide (=espace entre boutons)
124 Button(self.barreboutons,
125 image = images.get_image('Sep'),
127 relief = 'flat').pack(side='left')
129 nom_fic,commande,texte,statut = bouton
130 commande=getattr(appli_composant,commande)
131 b = Button(self.barreboutons,
132 image = images.get_image(nom_fic),
136 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t))
137 b.bind("<Leave>", self.efface_balloon)
138 b.bind("<Return>", lambda e,s=self,but=b,c=commande:s.appelle_commande(e,but,c))
139 if statut != 'always':
140 self.l_boutons_a_activer.append(b)
142 # inactive les boutons qui doivent l'être tant qu'aucun JDC courant
143 self.inactive_boutons()