def grabFileName(self): result = QFileDialog.getOpenFileName( self, "Open file", FileBrowseWidget.lastDirectory, self.fileTypeName) fname = result[0] if fname != '': fileInfo = QFileInfo(fname) try: FileBrowseWidget.lastDir = fileInfo.baseName() except: pass self.lineEdit.setText(fname)
def generateRFSettings(self): result = QFileDialog.getSaveFileName(self, "Save file", FileBrowseWidget.lastDirectory, "RF settings .yaml (*.yaml)") fname = result[0] if fname != '': fileInfo = QFileInfo(fname) try: FileBrowseWidget.lastDir = fileInfo.baseName() except: pass try: rf_settings = layout.parser.RFSettings.from_rand() timeNow = datetime.datetime.now().strftime("%Y-%M-%d at %H:%M") with open(fname, 'w') as outFile: outFile.write("# Generated on {}\n".format(timeNow) + rf_settings.to_yaml()) self.rfSettingsFile.lineEdit.setText(fname) except IOError as e: # TODO: proper error message print("error writing file: " + str(e))
def __fileNameWoExt(self): image = QFileInfo(self.directory + QDir.separator() + self.filename) return image.absoluteDir().absolutePath() + QDir.separator() + image.baseName()