def _save_protocol(self): output_file_name, used_filter = QFileDialog().getSaveFileName( caption='Save the protocol as', directory=self._opened_file, filter=';;'.join(protocol_files_filters)) if not output_file_name.endswith('.prtcl'): output_file_name = output_file_name + '.prtcl' if os.path.isdir( os.path.dirname(output_file_name)) and self._protocol.length: mdt.write_protocol(self._protocol, output_file_name) print('Saved protocol as: {}'.format(output_file_name))
def on_change_photo_button(self): grave = self.graves[self.current_index] photo_path = QFileDialog().getOpenFileName(self, 'Выбрать фотографию')[0] if not photo_path.endswith(('.jpg', '.png', '.jpeg', '.gif')): return None if photo_path.rfind('DCIM') != -1: relative_path = photo_path[photo_path.rfind('DCIM'):] elif photo_path.rfind('Photos') != -1: relative_path = photo_path[photo_path.rfind('Photos'):] else: relative_path = photo_path current_photo = self.photo_number.text() if current_photo == get_photo_number(grave.GetField(PHOTO)): self.save_photo_change(grave, PHOTO, relative_path) elif current_photo == get_photo_number(grave.GetField(PHOTO2)): self.save_photo_change(grave, PHOTO2, relative_path)
def _select_file(self): graphical_image_filters = [' '.join(el) for el in self._extension_filters] + ['All files (*)'] open_file, used_filter = QFileDialog().getSaveFileName(caption='Select the output file', filter=';;'.join(graphical_image_filters)) if not any(open_file.endswith(el[0]) for el in self._extension_filters): extension_from_filter = list(filter(lambda v: ' '.join(v) == used_filter, self._extension_filters)) if extension_from_filter: extension = extension_from_filter[0][0] else: extension = self._extension_filters[0][0] open_file += '.{}'.format(extension) if open_file: self.outputFile_box.setText(open_file) self._update_ok_button()