X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=InterfaceQT4%2FmonChoixCommande.py;h=09a0913f955481628f6db3efeffd633e39e308ef;hb=0dd3754f2c6ebee6f61a7aa505ed8711dd9ba79e;hp=af68c8af95acd6910ad28952c5c95550ce3f6723;hpb=1d010ff4e7d10301413f4760ae487291fcb2b2ca;p=tools%2Feficas.git diff --git a/InterfaceQT4/monChoixCommande.py b/InterfaceQT4/monChoixCommande.py index af68c8af..09a0913f 100644 --- a/InterfaceQT4/monChoixCommande.py +++ b/InterfaceQT4/monChoixCommande.py @@ -19,140 +19,288 @@ # Modules Python # Modules Eficas +from __future__ import absolute_import +try : + from builtins import str +except : pass + from desChoixCommandes import Ui_ChoixCommandes -from PyQt4 import * -from PyQt4.QtCore import * -from PyQt4.QtGui import * -from PyQt4.QtCore import * +from PyQt5.QtWidgets import QWidget, QAction ,QButtonGroup, QRadioButton, QLabel , QPushButton, QSpacerItem, QSizePolicy, QGridLayout +from PyQt5.QtGui import QIcon, QPixmap +from PyQt5.QtCore import QSize, QRect + from Extensions.i18n import tr import os # Import des panels -class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget): +class MonChoixCommande(Ui_ChoixCommandes,QWidget): """ """ def __init__(self,node, jdc_item, editor): - QtGui.QWidget.__init__(self,None) + QWidget.__init__(self,None) self.setupUi(self) - #self.labelIcone.setText(''); + + self.repIcon=os.path.join( os.path.dirname(os.path.abspath(__file__)),'..','Editeur','icons') + iconeFile=os.path.join(self.repIcon,'lettreRblanc30.png') + icon = QIcon(iconeFile) + self.RBRegle.setIcon(icon) + self.RBRegle.setIconSize(QSize(21, 31)) self.item = jdc_item self.node = node self.editor = editor self.jdc = self.item.object.get_jdc_root() - if self.editor.widgetTree != None: - self.connect(self.bFormulaire,SIGNAL("clicked()"),self.bFormulaireReturnPressed) - else : - self.bFormulaire.close() debutTitre=self.editor.titre self.listeWidget=[] + self.dicoCmd={} if self.editor.fichier != None : nouveauTitre=debutTitre+" "+str(os.path.basename(self.editor.fichier)) else : nouveauTitre=debutTitre self.editor.appliEficas.setWindowTitle(nouveauTitre) - self.connect(self.RBalpha,SIGNAL("clicked()"),self.afficheAlpha) - self.connect(self.RBGroupe,SIGNAL("clicked()"),self.afficheGroupe) - self.editor.labelCommentaire.setText("") - self.affiche_alpha=self.editor.affiche_alpha + + + self.RBalpha.clicked.connect(self.afficheAlpha) + self.RBGroupe.clicked.connect(self.afficheGroupe) + self.RBOrdre.clicked.connect(self.afficheOrdre) + self.RBClear.clicked.connect(self.clearFiltre) + self.RBCasse.toggled.connect(self.ajouteRadioButtons) + self.LEFiltre.returnPressed.connect(self.ajouteRadioButtons) + self.LEFiltre.textChanged.connect(self.ajouteRadioButtons) + + if self.node.tree.item.get_regles() == () : + self.RBRegle.close() + self.labelRegle.close() + else : + self.RBRegle.clicked.connect(self.afficheRegle) + + if self.editor.Ordre_Des_Commandes == None : self.RBOrdre.close() + + + #self.editor.labelCommentaire.setText("") + if self.editor.widgetOptionnel!= None : + self.editor.fermeOptionnel() + self.editor.widgetOptionnel=None self.name=None - self.AjouteRadioButton() - self.connect(self.LEFiltre,SIGNAL("returnPressed()"),self.AjouteRadioButton) + + self.affiche_alpha=0 + self.affiche_groupe=0 + self.affiche_ordre=0 + if self.editor.affiche=="alpha" : + self.affiche_alpha==1; + self.RBalpha.setChecked(True); + self.afficheAlpha() + elif self.editor.affiche=="groupe" : + self.affiche_groupe==1; + self.RBGroupe.setChecked(True); + self.afficheGroupe() + elif self.editor.affiche=="ordre" : + self.affiche_ordre==1; + self.RBOrdre.setChecked(True); + self.afficheOrdre() + if self.editor.closeFrameRechercheCommande == True : self.frameAffichage.close() + + if self.editor.widgetTree != None : self.editor.restoreSplitterSizes(2) + else: self.editor.restoreSplitterSizes(3) + + def afficheRegle(self): + self.node.tree.AppelleBuildLBRegles() def afficheAlpha(self): self.affiche_alpha=1 - self.editor.affiche_alpha=1 - self.AjouteRadioButton() + self.affiche_groupe=0 + self.affiche_ordre=0 + self.ajouteRadioButtons() def afficheGroupe(self): self.affiche_alpha=0 - self.editor.affiche_alpha=0 - self.AjouteRadioButton() + self.affiche_groupe=1 + self.affiche_ordre=0 + self.ajouteRadioButtons() - def bFormulaireReturnPressed(self): - print "PNPNPNPN a Programmer" - self.connect(self.bFormulaire,SIGNAL("clicked()"),self.bFormulaireReturnPressed) + def afficheOrdre(self): + self.affiche_alpha=0 + self.affiche_groupe=0 + self.affiche_ordre=1 + self.ajouteRadioButtons() - def mouseDoubleClickEvent(self,event): + def insereNoeudApresClick(self,event): + #print self.editor.Classement_Commandes_Ds_Arbre + #if self.editor.Classement_Commandes_Ds_Arbre!= () : self.chercheOu() + #print ('dans insereNoeudApresClick') nodeCourrant=self.node.tree.currentItem() if nodeCourrant==None: nodeCourrant=self.node.tree.racine if self.name != None : plier=self.editor.afficheCommandesPliees if nodeCourrant==self.node : nouveau=self.node.append_child(self.name,'first',plier) else : nouveau=nodeCourrant.append_brother(self.name,plier=plier) + else : + nouveau = 0 + if nouveau == 0 : return # on n a pas insere le noeud nouveau.setDeplie() #if self.editor.afficheApresInsert==True : nouveau.plieToutEtReaffiche() if self.editor.afficheApresInsert == True : - if self.editor.affichePlie ==True: nouveau.plieToutEtReaffiche() + #if self.editor.affichePlie==True: nouveau.plieToutEtReaffiche() + if self.editor.afficheCommandesPliees ==True: nouveau.plieToutEtReaffiche() else : nouveau.deplieToutEtReaffiche() + nouveau.fenetre.donnePremier() #nouveau.deplieToutEtReaffiche() + else : + self.node.setSelected(False) + nouveau.setSelected(True) + self.node.tree.setCurrentItem(nouveau) + if event != None : event.accept() + + - def CreeListeCommande(self,filtre): + def creeListeCommande(self,filtre): listeGroupes,dictGroupes=self.jdc.get_groups() - if "CACHE" in dictGroupes.keys(): + sensibleALaCasse=self.RBCasse.isChecked() + if "CACHE" in dictGroupes: aExclure=dictGroupes["CACHE"] else: aExclure=() listeACreer=[] for l in self.jdc.get_liste_cmd(): if l not in aExclure : - if filtre != None and not filtre in l : continue + if sensibleALaCasse and (filtre != None and not filtre in l) : continue + if (not sensibleALaCasse) and filtre != None and (not filtre in l) and (not filtre.upper() in l) : continue listeACreer.append(l) return listeACreer - def AjouteRadioButton(self): + def ajouteRadioButtons(self): + if self.editor.nombreDeBoutonParLigne != 0 : + self.ajoutePushButtons() + return + #print 'ds ajouteRadioButtons' filtre=str(self.LEFiltre.text()) if filtre==str("") : filtre=None if hasattr(self,'buttonGroup') : for b in self.buttonGroup.buttons(): self.buttonGroup.removeButton(b) + b.setParent(None) b.close() else : self.buttonGroup = QButtonGroup() for w in self.listeWidget : + w.setParent(None) w.close() self.listeWidget=[] if self.affiche_alpha==1 : - liste=self.CreeListeCommande(filtre) + liste=self.creeListeCommande(filtre) for cmd in liste : + self.dicoCmd[tr(cmd)]=cmd rbcmd=(QRadioButton(tr(cmd))) self.buttonGroup.addButton(rbcmd) self.commandesLayout.addWidget(rbcmd) - rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent - self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique) - else : + if self.editor.simpleClic : rbcmd.mouseReleaseEvent=self.insereNoeudApresClick + else : rbcmd.mouseDoubleClickEvent=self.insereNoeudApresClick + self.buttonGroup.buttonClicked.connect(self.rbClique) + elif self.affiche_groupe==1 : listeGroupes,dictGroupes=self.jdc.get_groups() for grp in listeGroupes: if grp == "CACHE" : continue label=QLabel(self) - text=QString.fromUtf8('

Groupe : '+tr(grp)+'

') + text=tr('

Groupe : '+tr(grp)+'

') label.setText(text) self.listeWidget.append(label) aAjouter=1 + sensibleALaCasse=self.RBCasse.isChecked() for cmd in dictGroupes[grp]: - if filtre != None and not filtre in cmd : continue + if sensibleALaCasse and (filtre != None and not filtre in cmd) : continue + if (not sensibleALaCasse) and filtre != None and (not filtre in cmd) and (not filtre.upper() in cmd) : continue if aAjouter == 1 : self.commandesLayout.addWidget(label) aAjouter=0 + self.dicoCmd[tr(cmd)]=cmd rbcmd=(QRadioButton(tr(cmd))) self.buttonGroup.addButton(rbcmd) self.commandesLayout.addWidget(rbcmd) - rbcmd.mouseDoubleClickEvent=self.mouseDoubleClickEvent - self.connect(self.buttonGroup, SIGNAL("buttonClicked(QAbstractButton*)"),self.rbClique) + if self.editor.simpleClic : rbcmd.mouseReleaseEvent=self.insereNoeudApresClick + else : rbcmd.mouseDoubleClickEvent=self.insereNoeudApresClick + self.buttonGroup.buttonClicked.connect(self.rbClique) label2=QLabel(self) label2.setText(" ") self.listeWidget.append(label2) self.commandesLayout.addWidget(label2) + elif self.affiche_ordre==1 : + listeFiltre=self.creeListeCommande(filtre) + liste=[] + if self.editor.Ordre_Des_Commandes == None : Ordre_Des_Commandes=listeFiltre + else : Ordre_Des_Commandes=self.editor.Ordre_Des_Commandes + for cmd in Ordre_Des_Commandes : + if cmd in listeFiltre : + liste.append(cmd) + for cmd in liste : + self.dicoCmd[tr(cmd)]=cmd + rbcmd=(QRadioButton(tr(cmd))) + self.buttonGroup.addButton(rbcmd) + self.commandesLayout.addWidget(rbcmd) + if self.editor.simpleClic : rbcmd.mouseReleaseEvent=self.insereNoeudApresClick + else : rbcmd.mouseDoubleClickEvent=self.insereNoeudApresClick + self.buttonGroup.buttonClicked.connect(self.rbClique) - def LEfiltreReturnPressed(self): - self.AjouteRadioButton(filtre) + def ajoutePushButtons(self): + if hasattr(self,'buttonGroup') : + for b in self.buttonGroup.buttons(): + self.buttonGroup.removeButton(b) + b.setParent(None) + b.close() + else : + self.buttonGroup = QButtonGroup() + self.buttonGroup.buttonClicked.connect(self.rbCliqueEtInsere) + for w in self.listeWidget : + w.setParent(None) + w.close() + self.listeWidget=[] + + if not hasattr(self,'maGrilleBouton') : + #self.commandesLayout.close() + self.maGrilleBouton=QGridLayout() + self.maGrilleBouton.setSpacing(20) + self.verticalLayout.addLayout(self.maGrilleBouton) + col=-1 + ligne = 0 + if self.affiche_alpha==1 : + liste=self.creeListeCommande(None) + for cmd in liste : + col=col+1 + if col == self.editor.nombreDeBoutonParLigne : + col=0 + ligne=ligne+1 + self.dicoCmd[tr(cmd)]=cmd + rbcmd=QPushButton(tr(cmd)) + rbcmd.setGeometry(QRect(40, 20, 211, 71)) + rbcmd.setMaximumSize(QSize(250, 81)) + rbcmd.setStyleSheet("background-color : rgb(66, 165, 238);\n" +"/*border-style : outset;*/\n" +"border-radius : 20px;\n" +"border-width : 30 px;\n" +"border-color : beige;\n" +"text-align : center") + if cmd in self.editor.dicoImages : + fichier=self.editor.dicoImages[cmd] + icon = QIcon() + icon.addPixmap(QPixmap(fichier), QIcon.Normal, QIcon.Off) + rbcmd.setIcon(icon) + rbcmd.setIconSize(QSize(48, 48)) + + self.buttonGroup.addButton(rbcmd) + self.maGrilleBouton.addWidget(rbcmd,ligne,col) + + def clearFiltre(self): + self.LEFiltre.setText("") + self.ajouteRadioButtons() + def rbCliqueEtInsere(self,id): + self.rbClique(id) + self.insereNoeudApresClick(None) def rbClique(self,id): - self.name=str(id.text().toLatin1()) + self.name=self.dicoCmd[str(id.text())] definitionEtape=getattr(self.jdc.cata[0],self.name) commentaire=getattr(definitionEtape,self.jdc.lang) try : @@ -162,7 +310,7 @@ class MonChoixCommande(Ui_ChoixCommandes,QtGui.QWidget): commentaire=getattr(definitionEtape,"ang") except : commentaire="" - self.editor.labelCommentaire.setText(commentaire) + self.editor.affiche_commentaire(commentaire)