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 inactive_boutons(self):
52 Inactive les boutons de la liste self.l_boutons_a_activer
53 --> cette méthode est appelée dès qu'il n'y a pas de JDC courant
55 for but in self.l_boutons_a_activer:
56 but.configure(state='disabled')
58 def active_boutons(self):
60 Active les boutons de la liste self.l_boutons_a_activer
61 --> cette méthode est appelée dès qu'il y a un JDC courant
63 for but in self.l_boutons_a_activer:
64 but.configure(state='normal')
66 def affiche_balloon(self,event,bouton,bulle,pos='left'):
68 Affiche le balloon bulle associé au bouton bouton
70 etat = bouton.cget('state')
71 if etat != 'normal' : return
72 geom = bouton.winfo_geometry()
73 l_args = string.split(geom,'+')
74 x = eval(l_args[1])+event.x+10
75 self.balloon = Label(self.parent,
81 self.balloon.place(in_=self.parent,x=x,y=32)
83 self.balloon.place(in_=self.parent,x=x,y=32,anchor='ne')
85 def efface_balloon(self,event=None):
87 Efface le balloon courant
90 self.balloon.destroy()
95 Permet d'afficher des infos sur la session courante d'EFICAS
97 self.fen_infos = Pmw.Dialog(self.parent,
98 title = 'Informations session EFICAS',
99 buttons = ('Fermer',),
100 command = self.close_infos)
101 self.fen_infos.withdraw()
102 texte_infos = self.appli.get_texte_infos()
103 Label(self.fen_infos.interior(),
105 anchor='center').pack(side='top',anchor='center')
106 self.fen_infos.activate(geometry = 'centerscreenalways')
108 def close_infos(self,lbl):
110 Ferme la fenêtre des infos
112 self.fen_infos.destroy()
114 def creer_boutons_appli_composant(self,l_boutons,appli_composant):
115 for bouton in l_boutons :
117 # on veut afficher un bouton vide (=espace entre boutons)
118 Button(self.barreboutons,
119 image = images.get_image('Sep'),
121 relief = 'flat').pack(side='left')
123 nom_fic,commande,texte,statut = bouton
124 commande=getattr(appli_composant,commande)
125 b = Button(self.barreboutons,
126 image = images.get_image(nom_fic),
130 b.bind("<Enter>",lambda e,s=self,but=b,t=texte : s.affiche_balloon(e,but,t))
131 b.bind("<Leave>", self.efface_balloon)
132 if statut != 'always':
133 self.l_boutons_a_activer.append(b)
135 # inactive les boutons qui doivent l'être tant qu'aucun JDC courant
136 self.inactive_boutons()