def keyPressEvent(self, event): """Méthode qui gère l'appui sur les touches du clavier""" super(SearchPerso, self).keyPressEvent(event) #Les propositions valables sont ts les tags et ts les acteurs self.propositions = listeTags() + listeActors() #On récupère le texte entré text = self.text() #Les propositions valables sont celles qui matchent le texte entré self.propositions = [ case for case in self.propositions if simpleChar(self.text()) in simpleChar(case) ] #Si le texte des boutons à droite ne matche pas ds la liste #des propositions, on cache le bouton, sinon on le montre for button in self.parent.liste_pressoirs_tags: if button.text() not in self.propositions: button.hide() else: button.show() for button in self.parent.liste_pressoirs_actors: if button.text() not in self.propositions: button.hide() else: button.show() if event.key() == QtCore.Qt.Key_Return and self.hasFocus() and len(self.propositions) == 1: for button in self.parent.liste_pressoirs_tags: if button.text() == self.propositions[0]: button.setChecked(True) button.clicked.emit(True) self.clear() self.parent.reshowButtons() for button in self.parent.liste_pressoirs_actors: if button.text() == self.propositions[0]: button.setChecked(True) button.clicked.emit(True) self.clear() self.parent.reshowButtons()
def __init__(self): super(DialogPerso, self).__init__() self.possible_tags = listeTags() self.initUI() self.etablirSlots()