Probleme mit event Handler

Python und das Qt-Toolkit, erstellen von GUIs mittels des Qt-Designers.
Antworten
doerflia
User
Beiträge: 20
Registriert: Freitag 3. Mai 2019, 14:49

Hi,

ich versuche folgendes zu programmieren:
Wenn in einer Select-Box das Feld "Traffic Sign" anmarkiert ist, soll die Group_box_sign "an" sein, ansonsten aus.

Das Problem:
Standardmäßig ist in der Select-Box das Feld "Traffic Sign" eingestellt, die Group_box_sign ist folglich aktiviert.
Wähle ich nun eine andere Option, so wird die Group_box_sign deaktiviert.
Soweit so gut. Das klappt wie gewünscht.
Doch sobald ich wieder auf "Traffic Sign" zurückwechsle bleibt die Group_box_sign deaktiviert,
obwohl sie wieder "an" sein sollte.

Hat jemand eine Idee??

Ein Teil meines Codes:

Code: Alles auswählen

....

            if radio_group_name == "Map Feature":    
                for idx, item in enumerate(items[1]): # creates all multiple chocies for the map feature categorie
                    self.combo_box_map_feature.addItem(item)
                
                layout_vbox_map_feature.addWidget(self.combo_box_map_feature) # add Widget for Map Feature element

                # listener for event handling
                self.combo_box_map_feature.activated.connect(self.feature_type_listener)
                
                # create GroupBox for Map Feature Selection and add it to the layout
                map_feature_group_box = QGroupBox(radio_group_name)
                map_feature_group_box.setLayout(layout_vbox_map_feature)
                
....
    def feature_type_listener(self):
        if self.combo_box_map_feature.currentText() == "TRAFFIC SIGN":
            self.group_box_sign.setEnabled(True)
        else:
            self.group_box_sign.setEnabled(False)
doerflia
User
Beiträge: 20
Registriert: Freitag 3. Mai 2019, 14:49

Problem gelöst indem ich
"self.combo_box_map_feature.currentText () == "TRAFFIC SIGN";
in
"self.sender().currentText () == "TRAFFIC SIGN";
geändert habe.
Antworten