コード例 #1
0
ファイル: hdrprocess.py プロジェクト: gobomus/hdrprocess
    def browse_curve_file(self, preferredExt="crv"):
        """
        Gets curve file from a file browser. If the returned string from the
        browser is a valid file, the curve input box is set to that new item
        and "Default Curve" and "Estimate Curve Only" are disabled

        Args:
            preferredExt (str): The extension that the browser will look for
                                whenever listing directories for a curve file
        """
        # make sure to filter out all unwanted files and leave a * (All Files)
        #
        filepaths = QtGui.QFileDialog.getOpenFileName(self, "Browse Curve Profile")
        filepaths = [x for x in filepaths if x.strip() != ""]

        for f in filepaths:
            if os.path.isfile(f) and f.lower().endswith(preferredExt):
                fname = paths.path_leaf(f)
                shutil.copy2(f, os.path.join(self.curveInputDir, fname))

                self.curveInput_cb.addItem(fname)
                index = self.curveInput_cb.findText(fname,
                                                    QtCore.Qt.MatchFixedString)
                if index >= 0:
                    self.curveInput_cb.setCurrentIndex(index)

                self.defaultCurve_cb.setEnabled(False)
                self.estimateCurve_cb.setEnabled(False)