Salome HOME
CCAR: creation V1_13a1 a partir de la branche Liv-V1_12
[tools/eficas.git] / Editeur / panels.py
index de19cf52bf5e6382aa1e560af420157347e963cf..636473a1ae0e852fbbf4a1fbd261bc02c8bb290c 100644 (file)
@@ -51,10 +51,11 @@ class Panel(Frame) :
       self.place(x=0,y=0,relheight=1,relwidth=1)
       self.creer_boutons()
       self.init()
+      global panneauCommande
+      panneauCommande=self
 
-  def __del__(self):
-      """ appele a la destruction du panel """
-      #print "PANEL DETRUIT"
+  #def __del__(self):
+  #    print "__del__",self
 
   def update_panel(self):
       """Methode appele pour demander une mise a jour du panneau"""
@@ -80,9 +81,9 @@ class Panel(Frame) :
       # On termine la suppression de facon brutale (objets Tk et non Tk)
       for k in self.__dict__.keys():
          # il est plus prudent de ne pas détruire le lien sur le Node
-        # si on voulait mettre l'attribut node à None, il faudrait
-        # que tous les appels à node.parent.select() apparaissent après
-        # toutes les autres actions liées au panel (node.item.isglobal(), ...)
+         # si on voulait mettre l'attribut node à None, il faudrait
+         # que tous les appels à node.parent.select() apparaissent après
+         # toutes les autres actions liées au panel (node.item.isglobal(), ...)
          if k != 'node' : setattr(self,k,None)
 
   def creer_boutons(self):
@@ -91,30 +92,29 @@ class Panel(Frame) :
       (à droite sous les onglets )
       """
       self.fr_but = Frame(self,height=30)
-      self.fr_but.pack(side='bottom',fill='x')
-      self.bouton_com = Button(self.fr_but,
-                               text = 'Commentariser',
-                               command = self.ajout_commentaire,
-                               width=14)
-      self.bouton_sup = Button(self.fr_but,
-                               text = "Supprimer",
-                               command=self.supprimer,
-                               width=14)
-      self.bouton_doc = Button(self.fr_but,
-                               text="Documentation",
-                               command=self.visu_doc,
-                               width=14)
-      self.bouton_cata = Button(self.fr_but,
-                                text = "Catalogue",
-                                command = self.show_catalogue,
-                                width=14)
+      self.fr_but.pack(side='bottom')
+      #self.fr_but.pack(side='bottom',fill='x')
+      #self.bouton_com = Button(self.fr_but, text = 'Commentariser', command = self.ajout_commentaire, width=14)
+      #self.bouton_sup = Button(self.fr_but, text = "Supprimer", command=self.supprimer, width=14)
+      #self.bouton_doc = Button(self.fr_but, text="Documentation", command=self.visu_doc, width=14)
+      #self.bouton_cata = Button(self.fr_but, text = "Catalogue", command = self.show_catalogue, width=14)
+      self.bouton_com = Button(self.fr_but, text = 'Commentariser', command = self.ajout_commentaire)
+      self.bouton_sup = Button(self.fr_but, text = "Supprimer", command=self.supprimer)
+      self.bouton_doc = Button(self.fr_but, text="Documentation", command=self.visu_doc)
+      self.bouton_cata = Button(self.fr_but, text = "Catalogue", command = self.show_catalogue)
+
       if self.parent.appli.CONFIGURATION.isdeveloppeur == 'OUI':
-          self.bouton_sup.place(relx=0.25,rely = 0.5,relheight = 0.8,anchor='center')
-          self.bouton_cata.place(relx=0.5,rely = 0.5,relheight = 0.8,anchor='center')
-          self.bouton_doc.place(relx=0.75,rely = 0.5,relheight = 0.8,anchor='center')
+          self.bouton_sup.pack(side='left',padx=5, pady=5)
+          self.bouton_cata.pack(side='left',padx=5, pady=5)
+          self.bouton_doc.pack(side='right',padx=5, pady=5)
+          #self.bouton_sup.place(relx=0.25,rely = 0.5,relheight = 0.8,anchor='center')
+          #self.bouton_cata.place(relx=0.5,rely = 0.5,relheight = 0.8,anchor='center')
+          #self.bouton_doc.place(relx=0.75,rely = 0.5,relheight = 0.8,anchor='center')
       else:
-          self.bouton_sup.place(relx=0.3,rely = 0.5,relheight = 0.8,anchor='center')
-          self.bouton_doc.place(relx=0.7,rely = 0.5,relheight = 0.8,anchor='center')
+          self.bouton_sup.pack(side='left',padx=5, pady=5)
+          self.bouton_doc.pack(side='right',padx=5, pady=5)
+          #self.bouton_sup.place(relx=0.3,rely = 0.5,relheight = 0.8,anchor='center')
+          #self.bouton_doc.place(relx=0.7,rely = 0.5,relheight = 0.8,anchor='center')
 
   def show_catalogue(self):
       try:
@@ -269,6 +269,8 @@ class OngletPanel(Panel) :
   """ Cette classe est virtuelle et doit être dérivée
       Elle contient les principales méthodes d'affichage des différents onglets"""
 
+  global panelbind
+
   def raisecmd(self,page):
       self.nb.page(page).focus_set()
       if page == 'Concept':
@@ -282,15 +284,44 @@ class OngletPanel(Panel) :
           except:
               pass
 
+  def creebind(self):
+       self.nb.bind_all("<F1>",lambda e,s=self,num=0:s.commande_up(num))
+       self.nb.bind_all("<F2>",lambda e,s=self,num=1:s.commande_up(num))
+       self.nb.bind_all("<F3>",lambda e,s=self,num=2:s.commande_up(num))
+       self.nb.bind_all("<F4>",lambda e,s=self,num=3:s.commande_up(num))
+       OngletPanel.panelbind=self.nb
+
+  def enlevebind(self):
+       if not hasattr(OngletPanel,"panelbind"):
+          return
+       if OngletPanel.panelbind == None:
+          return
+       try:
+           OngletPanel.panelbind.unbind_all("<F1>")
+           OngletPanel.panelbind.unbind_all("<F2>")
+           OngletPanel.panelbind.unbind_all("<F3>")
+           OngletPanel.panelbind.unbind_all("<F4>")
+       except:
+           pass
+       OngletPanel.panelbind = None
+
+  def commande_up(self,num):
+      #print "commande_up de panels pour ", num
+      try :
+        OngletPanel.panelbind.selectpage(num)
+        pageNew=OngletPanel.panelbind.page(num)
+        pageNew.focus_set()
+      except :
+        pass
 
   def affiche(self):
       page=self.nb.getcurselection()
       self.nb.page(page).focus_set()
       if page == 'Concept':
           try:
-#            _any est un pointeur sur entry
-#            component est une methode de pmw 
-#            a priori, jamais ok
+#              _any est un pointeur sur entry
+#              component est une methode de pmw 
+#              a priori, jamais ok
               self._any.component('entry').focus_set()
           except:
               pass
@@ -312,6 +343,8 @@ class OngletPanel(Panel) :
       self._any.bind("<Return>",lambda e,s=self:s.execConcept())
       self._any.bind("<KP_Enter>",lambda e,s=self:s.execConcept())
       self._any.insert(0,self.node.item.GetText())
+      self.but_ok=Button(page,text = "Valider",command=self.execConcept)
+      self.but_ok.place(relx=0.35,rely=0.8, relwidth=0.35)
       type_sd = self.node.item.get_type_sd_prod()
       if type_sd :
           txt = "L'opérateur courant retourne un objet de type %s" %type_sd
@@ -324,6 +357,7 @@ class OngletPanel(Panel) :
       page.bind("<Button-3>", lambda e,s=self,a=bulle_aide : s.parent.appli.affiche_aide(e,a))
       page.bind("<ButtonRelease-3>",self.parent.appli.efface_aide)
         
+
   def makeMoclesPage(self,page):
       """
       Crée la page qui affiche la liste des mots-clés que l'on peut
@@ -335,13 +369,16 @@ class OngletPanel(Panel) :
       liste_commandes = (("<Enter>",self.selectMC),
                          ("<Leave>",self.deselectMC),
                          ("<Double-Button-1>",self.defMC))
-      Liste = ListeChoix(self,page,liste_mc,liste_commandes = liste_commandes,titre = "Mots-clés permis")
+      Liste = ListeChoix(self,page,liste_mc,liste_commandes = liste_commandes,titre = "Mots-clés permis",optionReturn="oui")
       Liste.affiche_liste()
       # aide associée au panneau
       bulle_aide="""Double-cliquez sur le mot-clé que vous voulez ajouter à
       la commande en cours d'édition"""
       Liste.MCbox.bind("<Button-3>", lambda e,s=self,a=bulle_aide : s.parent.appli.affiche_aide(e,a))
       Liste.MCbox.bind("<ButtonRelease-3>",self.parent.appli.efface_aide)
+      if len(liste_mc) > 0 :
+         Liste.surligne(liste_mc[0])
+      self.Liste=Liste
 
   def makeCommentairePage(self,page):
       label = Label(page,text = "Insérer un commentaire :")
@@ -380,6 +417,7 @@ class OngletPanel(Panel) :
       bulle_aide="""Double-cliquez sur la commande que vous voulez ajouter au jeu de commandes"""
       Liste.MCbox.bind("<Button-3>", lambda e,s=self,a=bulle_aide : s.parent.appli.affiche_aide(e,a))
       Liste.MCbox.bind("<ButtonRelease-3>",self.parent.appli.efface_aide)
+      self.liste_command=Liste
       global panneauCommande
       panneauCommande=self
 
@@ -395,7 +433,7 @@ class OngletPanel(Panel) :
          Liste = ListeChoix(self,page,liste_cmd,liste_commandes = liste_commandes,
                             filtre='oui',titre = "Commandes",optionReturn="oui")
       else:
-         liste_commandes=liste_commandes+(("<Return>",self.defCmd),)
+         liste_commandes=liste_commandes+(("<Return>",self.defCmdFirst),)
          liste_groupes,dict_groupes=self.get_groups()
          Liste = ListeChoixParGroupes(self,page,liste_groupes,dict_groupes,
                                       liste_commandes = liste_commandes,
@@ -443,11 +481,9 @@ class OngletPanel(Panel) :
       # les frame ...
       self.frame_comment = Frame(page,bd=1,relief='raised')
       self.frame_param   = Frame(page,bd=1,relief='raised')
-      #self.frame_eval    = Frame(page,bd=1,relief='raised')
       self.frame_boutons = Frame(page,bd=1,relief='raised')
       self.frame_comment.place(relx=0,rely=0,relwidth=1,relheight=0.40)
       self.frame_param.place(relx=0,rely=0.40,relwidth=1,relheight=0.40)
-      #self.frame_eval.place(relx=0,rely=0.56,relwidth=1,relheight=0.28)
       self.frame_boutons.place(relx=0,rely=0.84,relwidth=1,relheight=0.16)
       # remplissage de la frame commentaire
       Label(self.frame_comment,text = "Insérer un commentaire :").place(relx=0.1,rely=0.5,anchor='w')
@@ -457,8 +493,8 @@ class OngletPanel(Panel) :
       but_comment_apres = Button(self.frame_comment,
                                  text = "APRES "+self.node.item.get_nom(),
                                  command = self.ajout_commentaire)
-      but_comment_avant.place(relx=0.6,rely=0.3,anchor='w',relwidth=0.3)
-      but_comment_apres.place(relx=0.6,rely=0.7,anchor='w',relwidth=0.3)
+      but_comment_avant.place(relx=0.45,rely=0.3,anchor='w',relwidth=0.45)
+      but_comment_apres.place(relx=0.45,rely=0.7,anchor='w',relwidth=0.45)
       # remplissage de la frame paramètre
       Label(self.frame_param,text = "Insérer un paramètre :").place(relx=0.1,rely=0.5,anchor='w')
       but_param_avant = Button(self.frame_param,
@@ -467,19 +503,8 @@ class OngletPanel(Panel) :
       but_param_apres = Button(self.frame_param,
                                  text = "APRES "+self.node.item.get_nom(),
                                  command = self.ajout_parametre)
-      but_param_avant.place(relx=0.6,rely=0.3,anchor='w',relwidth=0.3)
-      but_param_apres.place(relx=0.6,rely=0.7,anchor='w',relwidth=0.3)
-      # remplissage de la frame eval
-      #Label(self.frame_eval,text="Insérer un paramètre EVAL :").place(relx=0.1,rely=0.5,anchor='w')
-          #Label(self.frame_eval,text='Non encore disponible').place(relx=0.6,rely=0.5,anchor='w')
-      #but_eval_avant = Button(self.frame_eval,
-      #                        text = "AVANT "+self.node.item.get_nom(),
-      #                        command = lambda s=self :s.ajout_parametre_eval(ind = 'before'))
-      #but_eval_apres = Button(self.frame_eval,
-      #                        text = "APRES "+self.node.item.get_nom(),
-      #                        command = self.ajout_parametre_eval)
-      #but_eval_avant.place(relx=0.6,rely=0.3,anchor='w',relwidth=0.3)
-      #but_eval_apres.place(relx=0.6,rely=0.7,anchor='w',relwidth=0.3)      
+      but_param_avant.place(relx=0.45,rely=0.3,anchor='w',relwidth=0.45)
+      but_param_apres.place(relx=0.45,rely=0.7,anchor='w',relwidth=0.45)
       # remplissage de la frame boutons
       Button(self.frame_boutons,
              text="Commentariser toute la commande",
@@ -488,11 +513,6 @@ class OngletPanel(Panel) :
   def deselectMC(self,name):
       self.parent.appli.affiche_infos('')
     
-  def get_liste_cmd_BAK(self):
-      raise "OBSOLETE"
-      listeCmd = self.cata.listCmd()
-      return listeCmd
-
   def get_groups(self):
       jdc=self.node.item.object.get_jdc_root()
       return jdc.get_groups()