I would like to enable or disable the QDialogButtonBox or preferably only the OK button in QDialog, based on the selected text of two QComboBox(es).

My Example is as below. It is currently not working and the two ComboBoxes work independently of each other when enabling or disabling the QDialogButtonBox.

```
import sys

from PyQt5.QtCore import QSignalMapper, pyqtSlot
from PyQt5.QtWidgets import (QGroupBox, QFormLayout, QLabel, QComboBox,
                             QApplication, QDialog, QDialogButtonBox,
                             QVBoxLayout)

class SheetColumns(QDialog):
    def __init__(self, column_header):
        super().__init__()

        self.setMinimumWidth(300)
        self.setWindowTitle("Input Column Names")

        self.column_headers = column_header

        self.column_headers.insert(0, ' ')
        self.setWhatsThis('Please match columns in your data sheet names'
                          ' with the right side labels')

        col_names = ["Student Name:", "Student ID:", "Cohort:", "Gender:",
                     "College:", "Department:", "Major:", "Minor", "Email:",
                     "Adviser", "Adviser Email"]
        self.form_group_box = QGroupBox("Specify Column Names")
        self.layout = QFormLayout()
        for col_name in col_names:
            combo = QComboBox()
            combo.addItems(self.column_headers)
            self.layout.addRow(QLabel(col_name), combo)
        self.form_group_box.setLayout(self.layout)

        self.button_box = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        self.button_box.setEnabled(False)

        self.layout.itemAt(0, 1).widget().currentTextChanged.connect(
            self.check_validity)
        self.layout.itemAt(1, 1).widget().currentTextChanged.connect(
            self.check_validity)

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.form_group_box)
        main_layout.addWidget(self.button_box)
        self.setLayout(main_layout)

    def check_validity(self, text):
        print(text)
        if text == ' ':
            self.button_box.setEnabled(False)
        else:
            self.button_box.setEnabled(True)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    dialog = SheetColumns(['name student', 'id', 'cohort', 'test 1'])
    sys.exit(dialog.exec_())

```

I would like the QDialogButtonBox to be enabled when the currentText(s) in both ComboBoxes are something other than ' ', while it is being disabled when they are both ' '.

I attempted to use `QSignalMapper`. 

However, I could not manage to make it work.

```
class SheetColumns(QDialog):
    def __init__(self, column_header):
        super().__init__()

        self.setMinimumWidth(300)
        self.setWindowTitle("Input Column Names")

        self.column_headers = column_header

        self.column_headers.insert(0, ' ')
        self.setWhatsThis('Please match columns in your data sheet names'
                          ' with the right side labels')

        col_names = ["Student Name:", "Student ID:", "Cohort:", "Gender:",
                     "College:", "Department:", "Major:", "Minor", "Email:",
                     "Adviser", "Adviser Email"]
        self.form_group_box = QGroupBox("Specify Column Names")
        self.layout = QFormLayout()
        for col_name in col_names:
            combo = QComboBox()
            combo.addItems(self.column_headers)
            self.layout.addRow(QLabel(col_name), combo)
        self.form_group_box.setLayout(self.layout)

        self.button_box = QDialogButtonBox(
            QDialogButtonBox.Ok | QDialogButtonBox.Cancel)

        self.button_box.setEnabled(False)

        self.mapper = QSignalMapper(self)

        comb_bx1 = self.layout.itemAt(0, 1).widget()
        comb_bx2 = self.layout.itemAt(1, 1).widget()

        comb_bx1.currentTextChanged.connect(self.mapper.map)
        comb_bx2.currentTextChanged.connect(self.mapper.map)

        self.mapper.setMapping(comb_bx1, comb_bx1.currentText())
        self.mapper.setMapping(comb_bx2, comb_bx2.currentText())

        self.mapper.mapped.connect(self.check_validity)

        self.button_box.accepted.connect(self.accept)
        self.button_box.rejected.connect(self.reject)

        main_layout = QVBoxLayout()
        main_layout.addWidget(self.form_group_box)
        main_layout.addWidget(self.button_box)
        self.setLayout(main_layout)

    def check_validity(self, text):
        print(text)
        if text == ' ':
            self.button_box.setEnabled(False)
        else:
            self.button_box.setEnabled(True)

```

Could someone please tell me what I am doing wrong, or is there any better approach?

Thanks in advance