Do not connect to buttonBox.clicked, because it will be called for each button.
Your connections to the key boxes should look like this:
self.buttonBox.accepted.connect(Dialog.accept)
self.buttonBox.rejected.connect(Dialog.reject)
To start the function / slot when the dialog is accepted (i.e. only when you click OK), do the following:
self.accepted.connect(some_function)
If you want to pass a parameter, use lambda:
self.accepted.connect(lambda: some_function(param))
source
share