def show_file_save_browser_and_return_selection(self): if PYQT4: chosen_file = str( QtWidgets.QFileDialog.getSaveFileName(self, "Select file", '', 'XML files (*.xml)')) else: chosen_file, _filter =\ QtWidgets.QFileDialog.getSaveFileName( self, "Select file", '', 'XML files (*.xml)') chosen_file = str(chosen_file) if chosen_file == '': return chosen_file path_extension = os.path.splitext(chosen_file) if path_extension[1] == '.xml': return chosen_file else: updated_file = path_extension[0] + '.xml' if os.path.isfile(updated_file): if question( 'File {} already exists do you want to overwrite it?'. format(updated_file), parent=self): return path_extension[0] + '.xml' else: return '' return path_extension[0] + '.xml'
def show_file_save_browser_and_return_selection(self): chosen_file = str( QtWidgets.QFileDialog.getSaveFileName( self, "Select file", '', 'XML files (*.xml)')) if chosen_file == '': return chosen_file path_extension = os.path.splitext(chosen_file) if path_extension[1] == '.xml': return chosen_file else: updated_file = path_extension[0] + '.xml' if os.path.isfile(updated_file): if question('File {} already exists do you want to overwrite it?'.format(updated_file), parent=self): return path_extension[0] + '.xml' else: return '' return path_extension[0] + '.xml'