Example #1
0
    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
Example #2
0
    def fitfile(self):
        if self.fitc == None:
            msgBox = QMessageBox()
            msgBox.setText("Fit not yet executed!")
            msgBox.exec_()
            return -1

        msgBox = QMessageBox()
        msgBox.setText("Save correction file?")
        #msgBox.setInformativeText("A correction file will be saved in the root directory of the observation.")
        msgBox.addButton(QMessageBox.Cancel)
        msgBox.addButton(QMessageBox.Ok)
        msgBox.setDefaultButton(QMessageBox.Cancel)
        ret = msgBox.exec_()
        if ret != QMessageBox.Ok:
            return -1

        name = getsavefilename(self,
                               _("Save File"),
                               self.data_ref.dir_name + "/" + basename(
                                   normpath(self.data_ref.dir_name) + "_fit." +
                                   self.data_ref.files_type),
                               options=QFileDialog.DontConfirmOverwrite)
        if str(name[0]):
            if exists(str(name[0])):
                msgBox = QMessageBox()
                msgBox.setText("File exists!")
                msgBox.setInformativeText("Do you want to update it?")
                msgBox.addButton(QMessageBox.Cancel)
                msgBox.addButton(QMessageBox.Ok)
                msgBox.setDefaultButton(QMessageBox.Cancel)
                ret = msgBox.exec_()
                if ret != QMessageBox.Ok:
                    return -1

            self.data_ref.fitfile(str(name[0]), self.fitc)