Esempio n. 1
0
 def saveAs(self):
     if self.clswidgets.cls is None:
         return
     fname = str(getSaveFileNameDialogWithDefaultSuffix(self, 'Save file', '', 'CLS data (*.cat)', 'cat'))
     if len(fname) == 0:
         return
     self.saveFilename=fname
     self.saveAction.setEnabled(True)
     self._setWindowTitle()
     return self._save()
Esempio n. 2
0
    def savePdf(self):
        if self.clswidgets.cls is None:
            return
        # ask what to export: currently selected one or all CLS replicate groups
        dialog=ClsWidgets.PdfDialog()
        dialog.show()
        if not dialog.exec_():
            return
        # ask for filename
        fname = str(getSaveFileNameDialogWithDefaultSuffix(self, 'Save file', '', 'pdf (*.pdf)', 'pdf'))
        if len(fname) == 0:
            return

        if dialog.currentOrAllRadios.checkedId() == 0:
            # currently selected
            elementaryIndices=[]
            replicateGroupIndices=[]
            select=self.clswidgets.currentViewSelectionAsDict()
            addWellIdsToTitle=False
            if select['row1'] is None:
                replicateGroupIndices=[select['row0']]
            else:
                elementaryIndices=[self.clswidgets.cls.clsReplicateGroups[select['row0']].childWellIndices()[select['row1']]]
                addWellIdsToTitle=True
            platereader.clsplot.viabilitiesToPdf(self.clswidgets.cls,
                                                 fname,
                                                 showTitle=dialog.showTitle.checkState(),
                                                 addWellIdsToTitle=addWellIdsToTitle,
                                                 creator=os.path.basename(sys.argv[0]),
                                                 replicateGroupIndices=replicateGroupIndices,
                                                 elementaryIndices=elementaryIndices)
        elif dialog.currentOrAllRadios.checkedId() == 1:
            # all replicates
            # create progress bar, do not allow to press buttons, etc
            self._setupLongrunningCalculation('Saving figures',self.clswidgets.cls.numberOfNonBackgroundCls())
            try:
                platereader.clsplot.viabilitiesToPdf(self.clswidgets.cls,
                                                     fname,
                                                     showTitle=dialog.showTitle.checkState(),
                                                     creator=os.path.basename(sys.argv[0]),
                                                     replicateGroupIndices=[],
                                                     addWellIdsToTitle=False,progressCall=self._updateProgress)
            except Exception as err:
                exc_type, exc_value, exc_tb = sys.exc_info()
                msg=str(err)+"\n"
                if msg is None:
                    msg=''
                for line in traceback.format_exception(exc_type, exc_value, exc_tb):
                    msg+=line
                QtGui.QMessageBox.warning(self,'An error occurred',msg)
            # clean up: remove progress bar, enable buttons etc
            self._longrunningCalculationFinished()
        else:
            raise RuntimeError('PdfDialog: unknown selection')
Esempio n. 3
0
    def saveCsv(self):
        if self.clswidgets.cls is None:
            return
        fname = str(getSaveFileNameDialogWithDefaultSuffix(self, 'Save file', '', 'csv (*.csv)', 'csv'))
        if len(fname) == 0:
            return

        # create progress bar, do not allow to press buttons, etc
        self._setupLongrunningCalculation('Saving table',len(self.clswidgets.cls.clsReplicateGroups))
        # run the real calculation
        try:
            self.clswidgets.cls.survivalToCsv(fname,progressCall=self._updateProgress)
        except Exception as err:
            exc_type, exc_value, exc_tb = sys.exc_info()
            msg=str(err)+"\n"
            if msg is None:
                msg=''
            for line in traceback.format_exception(exc_type, exc_value, exc_tb):
                msg+=line
            QtGui.QMessageBox.warning(self,'An error occurred',msg)
        # clean up: remove progress bar, enable buttons etc
        self._longrunningCalculationFinished()