def apply_fit(self): msgBox = QMessageBox() msgBox.setText("Apply corrections?") msgBox.setInformativeText( "Select to which files will be applied the correction.") CancelButton = msgBox.addButton("Cancel", msgBox.RejectRole) SelectButton = msgBox.addButton("Select", msgBox.NoRole) AllButton = msgBox.addButton("All", msgBox.YesRole) #msgBox.setDefaultButton(QMessageBox.Cancel) msgBox.exec_() if msgBox.clickedButton() == CancelButton: return -1 elif msgBox.clickedButton() == AllButton: filelist = None elif msgBox.clickedButton() == SelectButton: flret = getopenfilenames(self, _("Select file list"), self.data_ref.dir_name)[0] filelist = [] for f in flret: filelist.append((basename(str(f)), dirname(str(f)))) msgBox = QMessageBox() msgBox.setText("Select the correction file") msgBox.addButton(QMessageBox.Ok) msgBox.exec_() filename = getopenfilename( self, _("Correction file"), self.data_ref.dir_name + "/" + basename( normpath(self.data_ref.dir_name) + "_fit." + self.data_ref.files_type)) try: self.data_ref.applycorr(str(filename[0]), filelist) except: msgBox = QMessageBox() msgBox.setText("Not a correction file!") msgBox.exec_() return -1